Skip to content

Instantly share code, notes, and snippets.

@TiGR
Last active August 29, 2015 14:06
Show Gist options
  • Save TiGR/4454205f4516e665312a to your computer and use it in GitHub Desktop.
Save TiGR/4454205f4516e665312a to your computer and use it in GitHub Desktop.
Integrate hamster-applet into KDE (stop tracking on screensaver)
#!/bin/bash
# this script makes hamster stop tracking once screensaver is started. Just like in gnome.
# just add this script to kde session autostart programs
# source: https://gist.github.com/TiGR/4454205f4516e665312a
dbus-monitor type='signal',interface='org.freedesktop.ScreenSaver',member='ActiveChanged',path='/org/freedesktop/ScreenSaver' | grep true --line-buffered |
while read line; do
# do hamster-cli stop only if there is actual activity running. If you just run hamster-cli stop when
# there is no activity running, previous activity end time would be set to current time.
# And yeah, there is no easy way to test if there is any activity running, so that's why this mess below
if test -z "`hamster-cli list | tail -n1 | sed -r 's/.*- *([^(]*) *\(.*/\1/'`"; then
hamster-cli stop;
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment