]> oss.titaniummirror.com Git - smckown/dotfiles.git/commitdiff
Add .Xidle
authorR. Steve McKown <rsmckown@gmail.com>
Sat, 26 Mar 2016 00:23:21 +0000 (18:23 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Sat, 26 Mar 2016 00:36:21 +0000 (18:36 -0600)
.Xidle is a script that will be called by xss-lock when started in
~/.dwmrc if it is present.  If this script is not present, xss-lock will
call i3lock directly.  If this script is present, it can do other stuff
before locking, and then more stuff after unlocking has completed.
Being used to suspend dunst messages and set XMPP status in mcabber.

i3lock execution has been changed to not use DPMS but instead a black
screen.  Hopefully this will solve some confusions where monitors that
are slow to sync don't provide enough feedback about what is going on.

Xidle [new file with mode: 0755]
dwmrc
install.sh

diff --git a/Xidle b/Xidle
new file mode 100755 (executable)
index 0000000..a6d67d8
--- /dev/null
+++ b/Xidle
@@ -0,0 +1,26 @@
+#!/bin/sh
+# This script should be called by xss-lock on no X activity.
+# xss-lock is started in ~/.dwmrc.
+
+# Set mcabber=1 if mcabber is present and running, else 0
+mcabber=0
+if [ -d ~/.mcabber ]; then
+  if [ -p ~/.mcabber/mcabber.fifo ]; then
+    mcabber=1
+  fi
+fi
+
+# Suspend dunst messages
+killall -SIGUSR1 -u $USER dunst 2>/dev/null
+
+# Mark idle in mcabber
+[ $mcabber -eq 1 ] && echo "/status away (Auto-idle)" > ~/.mcabber/mcabber.fifo
+
+# Lock the screen and wait until unlocked
+i3lock --nofork --color=000000
+
+# Mark online in mcabber
+[ $mcabber -eq 1 ] && echo "/status online -" > ~/.mcabber/mcabber.fifo
+
+# Resume dunst messages
+killall -SIGUSR2 -u $USER dunst 2>/dev/null
diff --git a/dwmrc b/dwmrc
index aeebe9a26518290289d8cda0987242b3dcb8f6db..a7baa093c62c3e149ca23aba8de06f6f2dcc2e88 100755 (executable)
--- a/dwmrc
+++ b/dwmrc
@@ -25,9 +25,20 @@ xsetroot -solid black
 dispcfg
 
 # Screen saver.  DPMS standby -> suspend -> off in seconds
-# xss-lock calls i3lock on no X activity (DPMS standby)
 xset dpms 300 600 1200
-(pgrep -x xss-lock || exec xss-lock -- i3lock --dpms ) &
+
+# Use xss-lock to call a program on no X activity (DPMS standby)
+if [ -x ~/.Xidle ]; then
+    # If provided, .Xidle can do stuff before and after a call to 'i3lock -n'
+    (pgrep -x xss-lock || exec xss-lock -- ~/.Xidle ) &
+elif [ -x /usr/bin/i3lock ]; then
+    # Fall back to i3lock, which provides a screen lock.
+    # Instead of --dpms use --color.  This is less confusing on monitors that
+    # are slow to sync back up.  And since X should generally have the monitor
+    # suspended by this point anyway, the behavior should only change in the
+    # case of things like an invalid password being entered.
+    (pgrep -x xss-lock || exec xss-lock -- i3lock --color=000000 ) &
+fi
 
 # Turn off touchpad (later use a toggle)
 type synclient 2>/dev/null && synclient TouchpadOff=1
index c2c947f74dc9de3e74306a780989cc8d79d60684..2028bc694f4cced87e1ca10d28cf41f2b62a227f 100755 (executable)
@@ -49,3 +49,4 @@ dolink ../.dotfiles/ssh_config  .ssh/config
 dolink ../.dotfiles/mcabberrc  .mcabber/mcabberrc
 dolink ../.dotfiles/mcabber.eventcmd  .mcabber/eventcmd
 dolink ../../.dotfiles/profrc .config/profanity/profrc
+dolink .dotfiles/Xidle .Xidle