From b7dfa5fdb2330f1e1cd222365055c3d45ad473be Mon Sep 17 00:00:00 2001 From: Rose Date: Fri, 10 Oct 2025 11:29:10 +0200 Subject: all: Rework system structure --- desktop/Local/bin/barstatus | 8 ++++++++ desktop/Local/bin/kittenbar | 4 ++++ desktop/Local/share/barmodules/battery.sh | 3 +++ desktop/Local/share/barmodules/enabled/mpv.sh | 1 + desktop/Local/share/barmodules/enabled/qmmp.sh | 1 + desktop/Local/share/barmodules/ice.sh | 21 +++++++++++++++++++++ desktop/Local/share/barmodules/mpv.sh | 8 ++++++++ desktop/Local/share/barmodules/qmmp.sh | 13 +++++++++++++ 8 files changed, 59 insertions(+) create mode 100755 desktop/Local/bin/barstatus create mode 100755 desktop/Local/bin/kittenbar create mode 100755 desktop/Local/share/barmodules/battery.sh create mode 120000 desktop/Local/share/barmodules/enabled/mpv.sh create mode 120000 desktop/Local/share/barmodules/enabled/qmmp.sh create mode 100755 desktop/Local/share/barmodules/ice.sh create mode 100755 desktop/Local/share/barmodules/mpv.sh create mode 100755 desktop/Local/share/barmodules/qmmp.sh (limited to 'desktop/Local') diff --git a/desktop/Local/bin/barstatus b/desktop/Local/bin/barstatus new file mode 100755 index 0000000..ecb461c --- /dev/null +++ b/desktop/Local/bin/barstatus @@ -0,0 +1,8 @@ +#!/bin/sh +echo -n "SPKR: $(wpctl get-volume @DEFAULT_AUDIO_SINK@ 2> /dev/null | sed 's/0\.//g' | sed 's/\.//g' )% ; MIC: $(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ 2> /dev/null | sed 's/0\.//g' | sed 's/\.//g')%" +echo -n " | " +echo -n "$(date)" +for f in ${HOME}/.local/share/barmodules/enabled/*; do + echo -n " | " + [ -x "$f" ] && [ ! -d "$f" ] && "$f" +done diff --git a/desktop/Local/bin/kittenbar b/desktop/Local/bin/kittenbar new file mode 100755 index 0000000..a2b14c2 --- /dev/null +++ b/desktop/Local/bin/kittenbar @@ -0,0 +1,4 @@ +#!/bin/sh +kitten panel -o allow_remote_control=socket-only \ + --lines=1 \ + --listen-on=unix:${XDG_RUNTIME_DIR}/kittenbar watch -t -n1 /home/lain/.local/bin/barstatus diff --git a/desktop/Local/share/barmodules/battery.sh b/desktop/Local/share/barmodules/battery.sh new file mode 100755 index 0000000..9ff7330 --- /dev/null +++ b/desktop/Local/share/barmodules/battery.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo -n "BATTERY: $(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep 'percentage' | tr -d ' ' | sed 's/:/: /g'); " +echo -n "$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep 'state' | tr -d ' ' | sed 's/:/: /g')" diff --git a/desktop/Local/share/barmodules/enabled/mpv.sh b/desktop/Local/share/barmodules/enabled/mpv.sh new file mode 120000 index 0000000..d0c9416 --- /dev/null +++ b/desktop/Local/share/barmodules/enabled/mpv.sh @@ -0,0 +1 @@ +../mpv.sh \ No newline at end of file diff --git a/desktop/Local/share/barmodules/enabled/qmmp.sh b/desktop/Local/share/barmodules/enabled/qmmp.sh new file mode 120000 index 0000000..7a7bc04 --- /dev/null +++ b/desktop/Local/share/barmodules/enabled/qmmp.sh @@ -0,0 +1 @@ +../qmmp.sh \ No newline at end of file diff --git a/desktop/Local/share/barmodules/ice.sh b/desktop/Local/share/barmodules/ice.sh new file mode 100755 index 0000000..ae04fcc --- /dev/null +++ b/desktop/Local/share/barmodules/ice.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +iceStatus=$(curl https://iceportal.de/api1/rs/status 2>/dev/null) +iceTrip=$(curl https://iceportal.de/api1/rs/tripInfo/trip 2> /dev/null) + +nextStopID=$(echo ${iceTrip} | jq -r .trip.stopInfo.actualNext) +nextStopObject=$(echo ${iceTrip} | jq -c ".trip.stops | map(select(.station.evaNr == \"${nextStopID}\"))") + +scheduledArrival=$(echo ${nextStopObject} | jq -r ".[0].timetable.scheduledDepartureTime/1000") +actualArrival=$(echo ${nextStopObject} | jq -r ".[0].timetable.actualArrivalTime/1000") +arrivalDelay=$(echo ${nextStopObject} | jq -r ".[0].timetable.arrivalDelay") + +trainDistanceSinceStop=$(echo ${iceTrip} | jq -r ".trip.distanceFromLastStop") +nextStopDistance=$(echo ${nextStopObject} | jq -r "(.[0].info.distance-${trainDistanceSinceStop})/1000") + + +echo -n "ICE $(echo ${iceTrip} | jq -r '.trip.vzn'): " +echo -n "Speed: $(echo ${iceStatus} | jq -r '.speed')km/h; " +echo -n "Next Stop: $(echo ${nextStopObject} | jq -r '.[0].station.name') " +echo -n $(date --date="@${actualArrival}" +"%H:%M")" (${arrivalDelay}) " +echo -n "${nextStopDistance}km" diff --git a/desktop/Local/share/barmodules/mpv.sh b/desktop/Local/share/barmodules/mpv.sh new file mode 100755 index 0000000..a3fe2ec --- /dev/null +++ b/desktop/Local/share/barmodules/mpv.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ -f /tmp/mpvout ]; then + echo -n "mpv: " + tail -1 /tmp/mpvout | tr -d '\n' +else + echo -n "mpv: stopped" +fi diff --git a/desktop/Local/share/barmodules/qmmp.sh b/desktop/Local/share/barmodules/qmmp.sh new file mode 100755 index 0000000..a0ec01e --- /dev/null +++ b/desktop/Local/share/barmodules/qmmp.sh @@ -0,0 +1,13 @@ +#!/bin/sh +pidof qmmp 2> /dev/null > /dev/null +if [ $? -eq 0 ]; then + nowplaying=$(qmmp --nowplaying '%p - %a: %t') + if [ ${#nowplaying} -gt 80 ]; then + echo -n "${nowplaying:0:77}... " + else + echo -n "$nowplaying" + fi + echo -n "$(qmmp --status | head -1)" +else + echo -n "qmmp: Exited" +fi -- cgit v1.2.3