Skip to content

Instantly share code, notes, and snippets.

@zphixon
Created June 7, 2017 01:45
Show Gist options
  • Save zphixon/9b9b608056c7972d2d8605715c4b7bf5 to your computer and use it in GitHub Desktop.
Save zphixon/9b9b608056c7972d2d8605715c4b7bf5 to your computer and use it in GitHub Desktop.
#!/bin/zsh
function popup() {
# how long bar stays open
duration=4
# color of bar
bar_bg='#4265f4'
# bar position
bar_x='200'
bar_y='0'
# txtw: https://github.com/baskerville/txtw
# somewhat janky with default x font
# width of message for bar dimensions
width=$(txtw $1)
# set up bar geometry
# <width>x<height>+<x>+<y>
# use default height of whatever
geom="${width}x+${bar_x}+${bar_y}"
# show bar
( echo "%{c}$1"; sleep $duration ) | lemonbar -g $geom -B $bar_bg
}
# sind: https://github.com/htylo/simplenotifydaemon
# custom format: appname:summary:description
# the default format is kind of weird
sind -f "%a:%s:%b" | while IFS=: read app sum desc; do
# sometimes sind emits an empty line
if [ "$app" != " " ]; then
# message to send to bar
message="$app"
if [ "$sum" != " " ] && [ -n "$sum" ]; then
message="$message - $sum"
fi
if [ "$desc" != " " ] && [ -n "$desc" ]; then
message="$message - $desc"
fi
# run popup
popup $message
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment