~scripts
55 itemsDownload ./*

55 itemsDownload ./*

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


scriptsslocker
2 683•  8 years ago•  DownloadRawClose
8 years ago•  2 683

{}
#!/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 029 786 visits
... ^ v