From b00bd3ebff38782c474269883d6004906ffab5c9 Mon Sep 17 00:00:00 2001 From: Quentin Duchemin Date: Thu, 14 Nov 2019 15:53:55 +0100 Subject: [PATCH] Add a film mode to pause notifications and autolock --- .config/i3/config_common | 3 +++ .config/i3/scripts/film_mode.sh | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 .config/i3/scripts/film_mode.sh diff --git a/.config/i3/config_common b/.config/i3/config_common index 9ef56e6..4c5ee12 100644 --- a/.config/i3/config_common +++ b/.config/i3/config_common @@ -94,6 +94,9 @@ bindsym $mod+Print exec ~/.config/i3/scripts/screenshot.py -s # screenshot and upload to Lychee bindsym Print exec ~/.config/i3/scripts/screenshot.py -u +# toggle film mode +bindsym $mod+Shift+f exec ~/.config/i3/scripts/film_mode.sh + ################################## # BINDINGS FOR STANDARD OPERATIONS ################################## diff --git a/.config/i3/scripts/film_mode.sh b/.config/i3/scripts/film_mode.sh new file mode 100755 index 0000000..e78c00d --- /dev/null +++ b/.config/i3/scripts/film_mode.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +ON=on +OFF=off + +function usage() { + echo "$0: turn on or off the film mode, i.e. killall disturbing apps, autolock and notification daemon" + echo "usage: $0 [on|off]" + echo "if no argument is specified, try to guess whether film mode is on or off and toggle" + exit 0 +} + +function on() { + killall xautolock + xset dpms 0 + # expire before pausing dunst so the notification does not show up at resume + notify-send -i "vlc" -t "1900" -u "normal" -a "Film Mode" "On !" + sleep 2 + # pause dunst, continue receive notification + killall -SIGUSR1 dunst +} + +function off() { + # resume dunst, show all dangling notifications + killall -SIGUSR2 dunst + xautolock -time 9 -locker ~/.config/i3/lock/lock.sh & + xset dpms 600 + notify-send -i "vlc" -t "1900" -u "normal" -a "Film Mode" "Off !" +} + +if [ "${1}" == "${ON}" ]; then + on +elif [ "${1}" == "${ON}" ]; then + off +else + pgrep xautolock &>/dev/null + if [ $? == "0" ]; then + on + else + off + fi +fi