~scripts
58 itemsDownload ./*

58 itemsDownload ./*

..
display
dzen2
nginx
tiling
vosh
4cdl
4trips
alarm
ambient
battery-monitor
checkit
cleverbot.py
clock
color-gen
colors-hex
colorscheme.sh
compton.sh
dailywall
dmenu
ffthumb
grid
gridmacro
gridmacro.kde
help
importw
indexer
install-all.sh
install-twily.sh
installng
mp3ogg
netspeed.sh
orage
pipes
pipes.x
pipewire_bt.sh
ports
rain
randwall
readystart.sh
rotate.sh
scan.sh
screencast
screencast2
scrot
scrotw
search
skull
slocker
startblender.sh
starwars
streamit
sumnum
synctimedate.sh
tty-colorize
usrmount
ytp
ytplay
zombie-restart.sh


scriptsslocker
2 879•  9 years ago•  DownloadRawClose
9 years ago•  2 879

{}
#!/bin/bash
#
#   Author:         Twily                                                  2014 - 2015
#   Description:    Locks the screen once the monitor goes to 'off' state w/ slideshow
#   Requires:       xset, xbacklight, xtrlock, xdotool, feh || firefox || surf
#
#   Usage:          Use keybind to '$ sh ./slocker lock' to trigger manually
#                   (if MLOCK=false and slocker is running in the background)
#
#                   Use '$ sh ./slocker' to lock if MLOCK=true
#

MLOCK=false         # Lock manually only? [true|false]
PLOCK=false         # Lock with password? [true|false]

function displaypic() {
    # Open fullscreen picture w/ feh

    # Slideshow
    #feh -zxFY -D 5 --auto-zoom ~/Pictures/lewd\ pony/ponyporn/*/*

    # How to make Firefox "fullscreen" Profile http://pastebin.com/Gi5ke4WK
    # homepage.html: http://twily.info/firefox/homepage-sidebar.html#view
    firefox-nightly -P "fullscreen" -no-remote ~/sidebar-homepage.porn.html

    # slideshow.html: http://twily.info/firefox/slideshow.html#view
    #surf -f ~/slideshow.porn.html

    # Static
    #feh -xFY --zoom fill ~/lewd-twily.jpg
}

function lockscreen() {
    # Attempt to dim the screen backlight
    XBL=$(xbacklight -get)
    xbacklight -set 0

    # Optional: Turn monitor back on once locked
    xset dpms force on

    echo -e "slocker: \033[1;31mScreen has been locked.\033[0m"
    if $PLOCK; then
        displaypic &

        # Lock screen w/ xtrlock
        if $MLOCK; then sleep .2 && xtrlock
        else xtrlock; fi

        ### Waiting for password input ###

        # Kill feh
        pkill -P $!
    else displaypic; fi
    echo -e "slocker: \033[1;32mScreen has been unlocked.\033[0m"

    # Reset backlight to $XBL
    xbacklight -set $XBL
}

if [ "$1" == "lock" ]; then
    if ! $MLOCK; then
        # Turn monitor off
        sleep .2 && xset dpms force off
        exit 0
    fi
fi
if $MLOCK; then lockscreen && exit 0; fi

echo -e "slocker: \033[1;33mWaiting for monitor 'off' state...\033[0m"

while true; do
    MON=$(xset -q|grep 'Monitor is')
	
    if [[ $MON == *Off* ]]; then
        lockscreen
        echo -e "slocker: \033[1;33mWaiting for monitor 'off' state...\033[0m"
    fi

    sleep 1
done

exit 0

Top
©twily.info 2013 - 2024
twily at twily dot info



2 160 666 visits
... ^ v