Last active
April 23, 2024 14:46
-
-
Save dr0bz/7b1ce98138383f9a4d9d6772a0b13af6 to your computer and use it in GitHub Desktop.
Waybar hamster module (custom/hamster) https://github.com/projecthamster/hamster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#custom-hamster.has-activity { | |
color: #839e00; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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