Skip to content

Instantly share code, notes, and snippets.

@dr0bz
Last active April 23, 2024 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dr0bz/7b1ce98138383f9a4d9d6772a0b13af6 to your computer and use it in GitHub Desktop.
Save dr0bz/7b1ce98138383f9a4d9d6772a0b13af6 to your computer and use it in GitHub Desktop.
Waybar hamster module (custom/hamster) https://github.com/projecthamster/hamster
#!/bin/bash
activity=`hamster current`
if [[ $activity == "No activity" ]]; then
text=""
class=""
else
start_date=`echo $activity | cut -d' ' -f1`
start_time=`echo $activity | cut -d' ' -f2`
name=`echo $activity | sed 's/[0-9\-]\+\s[0-9\:]\+[[:space:]]\([[:alnum:] \.,@-]\+\)[[:space:]][0-9\:]\+/\1/'`
duration=`echo $activity | sed 's/.*\([0-9\:]\{2\}:[0-9\:]\{2\}\)/\1/g'`
text="${duration} ${name}"
class="has-activity"
fi
tooltip=`hamster list day`
tooltip="${tooltip//$'\n'/\\n}"
output="{ \"text\": \"$text\", \"tooltip\": \"<tt>$(echo "$tooltip")</tt>\", \"class\": \"$class\" }"
echo "$output"
#custom-hamster.has-activity {
color: #839e00;
}
{
"custom/hamster": {
"exec": "~/.config/waybar/scripts/hamster.sh",
"on-click": "hamster add",
"on-click-right": "hamster",
"on-click-middle": "hamster stop",
"interval": 1,
"return-type": "json"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment