Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.