commit c70be5606d7cfcc5c40f5ad367804be02c85467f
parent 16d066432a2652130464d17db6434c1e4e4aea2d
Author: Mark Feller <mfeller@recurly.com>
Date: Wed, 18 Dec 2019 14:00:14 -0700
shellcheck scripts
Signed-off-by: Mark Feller <mfeller@recurly.com>
Diffstat:
4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/dots/.local/bin/notify-date b/dots/.local/bin/notify-date
@@ -2,4 +2,7 @@
# Display the date using notify-send
# A nice alternative to displaying the time on a bar.
-notify-send -t 5000 "$(date +"%A, %-d %b %-I:%M")"
+# Arbitrary but unique message id
+msgId="661049"
+
+dunstify -r $msgId -t 5000 "$(date +"%A, %-d %b %-I:%M")"
diff --git a/dots/.local/bin/notify-mpd b/dots/.local/bin/notify-mpd
@@ -1,13 +1,16 @@
#!/bin/sh
# Send notifications when mpd song changes
+# Arbitrary but unique message id
+msgId="661050"
+
tmp="/tmp/cover.jpg"
form="Artist: %artist%\nAlbum: %album%\nTitle: %title%"
rm -f $tmp
# create the notification text
-toprint="`mpc status -f \"$form\" | head -n3 | sed \"s:&:&:g\"`"
+toprint="$(mpc status -f "$form" | head -n3 | sed \"s:&:&:g\")"
artpath="/home/mjf/Music/$(dirname "$(mpc status -f '%file%' | head -n1)")/cover.jpg"
# generate the cover icon if we find one
@@ -16,4 +19,4 @@ if [ -f "$artpath" ]; then
fi
# send out the notication with the cover icon and song information
-notify-send -i "$tmp" "$toprint"
+dunstify -r $msgId -i "$tmp" "$toprint"
diff --git a/dots/.local/bin/power-status b/dots/.local/bin/power-status
@@ -1,5 +1,8 @@
#!/bin/sh
-status=`upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" | sed "s/: */: /" | sed "s/^ *//"`
+# Arbitrary but unique message id
+msgId="661051"
-notify-send "Power" "$status"
+status=$(upower -i "$(upower -e | grep BAT)" | grep --color=never -E "state|to\ full|to\ empty|percentage" | sed "s/: */: /" | sed "s/^ *//")
+
+dunstify -r $msgId "Power" "$status"
diff --git a/dots/.local/bin/volume-change b/dots/.local/bin/volume-change
@@ -1,9 +1,21 @@
#!/bin/sh
-SINK=$( pactl list short sinks | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' | head -n 1 )
+# Arbitrary but unique message id
+msgId="661051"
-pactl -- set-sink-volume $SINK $1
+# Get the current sink
+SINK=$(pactl list short sinks \
+ | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' \
+ | head -n 1)
-NOW=$( pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
+# Update the volume
+pactl -- set-sink-volume "$SINK" "$1"
-notify-send "<b>Volume</b> ${NOW}%"
+# Get the current volume percentage
+NOW=$(pactl list sinks \
+ | grep '^[[:space:]]Volume:' \
+ | head -n $(( "$SINK" + 1 )) \
+ | tail -n 1 \
+ | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
+
+dunstify -r $msgId "<b>Volume</b> ${NOW}%"