Skip to content

Instantly share code, notes, and snippets.

@GermaniumSystem
Created February 28, 2019 23:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GermaniumSystem/d6eb8ac507f219acae1ee8630e12eb03 to your computer and use it in GitHub Desktop.
Save GermaniumSystem/d6eb8ac507f219acae1ee8630e12eb03 to your computer and use it in GitHub Desktop.
#!/bin/bash
DEBUG=1
# Indicator string as seen in dbus messages. Will probably change frequently.
DM_INDICATOR='chrome_app_indicator2_5dc5a4d4fc9f0cfd05f90bfbb2390e06'
function debugEcho {
if [ "$DEBUG" -eq 1 ] ; then
echo "$@"
fi
}
# Force the LED off on startup.
xset -led 3
# Monitor the session dbus for messages indicating that Slack's icon changed.
dbus-monitor "type=method_return" | grep --line-buffered -Eo 'chrome_app_indicator2_[^"]+' | while read indicator ; do
# If the new icon equals the known DM_INDICATOR icon, turn on the light.
if [[ "$indicator" == "$DM_INDICATOR" ]] ; then
debugEcho "[[ \"$indicator\" == \"$DM_INDICATOR\" ]]"
xset led 3
# Otherwise, turn it off.
else
debugEcho "[[ \"$indicator\" != \"$DM_INDICATOR\" ]]"
xset -led 3
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment