2021-03-11 00:07:19 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-01-07 20:09:50 +02:00
|
|
|
# create fifo
|
|
|
|
fifo="${XDG_RUNTIME_DIR}/statusupdated"
|
|
|
|
|
|
|
|
mkfifo "${fifo}"
|
|
|
|
trap "echo 'exit' > '${fifo}' ; rm -f '${fifo}'" EXIT
|
|
|
|
|
|
|
|
extra=""
|
|
|
|
message=""
|
|
|
|
media_name=""
|
|
|
|
date_value=""
|
|
|
|
|
|
|
|
dark_medium="#282828"
|
|
|
|
dark_hard="#1d2021"
|
|
|
|
dark_soft="#32302f"
|
|
|
|
red="#ea6962"
|
|
|
|
green="#a9b665"
|
|
|
|
yellow="#d8a657"
|
|
|
|
blue="#7daea3"
|
|
|
|
magenta="#d3869b"
|
|
|
|
cyan="#89b482"
|
|
|
|
white="#d4be98"
|
|
|
|
|
|
|
|
|
|
|
|
clean() {
|
|
|
|
rm -f "${fifo}"
|
|
|
|
}
|
|
|
|
|
|
|
|
getstatus() {
|
|
|
|
data=""
|
|
|
|
if [ ! -z "${extra}" ]; then
|
|
|
|
data="${data}${extra} •"
|
|
|
|
fi
|
|
|
|
if [ ! -z "${message}" ]; then
|
|
|
|
data="${data}^c${magenta}^ ^d^${message} •"
|
|
|
|
fi
|
|
|
|
if [ ! -z "${media_name}" ]; then
|
|
|
|
data="${data}^c${magenta}^ ^d^${media_name} •"
|
|
|
|
fi
|
|
|
|
if [ ! -z "${date_value}" ]; then
|
|
|
|
data="${data}^c${magenta}^ ^d^${date_value}"
|
|
|
|
fi
|
|
|
|
echo "${data}"
|
|
|
|
}
|
|
|
|
|
|
|
|
updatestatus() {
|
|
|
|
xsetroot -name "$(getstatus)"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
if read fifoline < $fifo; then
|
|
|
|
case "${fifoline}" in
|
|
|
|
set_message*)
|
|
|
|
# cuts after ::
|
|
|
|
# example: `set_message::nice day outside`
|
|
|
|
message="${fifoline##*::}"
|
|
|
|
;;
|
|
|
|
set_media_name*)
|
|
|
|
# cuts after ::
|
|
|
|
# example: `set_media_name::Song Name Goes Here`
|
|
|
|
media_name="${fifoline##*::}"
|
|
|
|
;;
|
|
|
|
set_date_value*)
|
|
|
|
# cuts after ::
|
|
|
|
# example: `set_date_value::Date Goes Here`
|
|
|
|
date_value="${fifoline##*::}"
|
|
|
|
;;
|
|
|
|
set_extra*)
|
|
|
|
# cuts after ::
|
|
|
|
# example `set_extra::something happened`
|
|
|
|
extra="${fifoline##*::}"
|
|
|
|
;;
|
|
|
|
update)
|
|
|
|
;;
|
|
|
|
exit)
|
|
|
|
echo "statusupdated: warn: got exit command, exiting..."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
updatestatus
|
|
|
|
fi
|
|
|
|
done &
|
|
|
|
|
|
|
|
# send the time string every 30 seconds through the FIFO
|
2021-03-11 00:07:19 +02:00
|
|
|
while :
|
|
|
|
do
|
2022-01-07 20:09:50 +02:00
|
|
|
echo "set_date_value::$(date '+%a %d %b %-I:%M')" > "${fifo}"
|
|
|
|
sleep 30
|
2021-03-11 00:07:19 +02:00
|
|
|
done
|