Last active
November 21, 2017 11:35
-
-
Save faniska/6d6c40470ff24c149523112f8208526a to your computer and use it in GitHub Desktop.
Notify and lock screen on Ubuntu Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)" | |
/usr/bin/notify-send -i face-wink "Пятиминутка" "Сделай паузу!" | |
/bin/sleep 2 | |
loginctl lock-session 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get_display [USER] -- Returns $DISPLAY of USER. | |
# If first param is omitted, then $LOGNAME will be used. | |
get_display () { | |
who \ | |
| grep ${1:-$LOGNAME} \ | |
| perl -ne 'if ( m!\(\:(\d+)\)$! ) {print ":$1.0\n"; $ok = 1; last} END {exit !$ok}' | |
} | |
DISPLAY=$(get_display) || exit | |
export DISPLAY | |
/usr/bin/notify-send -i face-wink "Пятиминутка" "Сделай паузу!" | |
/bin/sleep 2 | |
loginctl lock-session 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment