wob: implement as part of sway instead of exclusive to sxmo

This commit is contained in:
Colin 2024-01-04 13:07:35 +00:00
parent 43498c62f9
commit daf046861c
4 changed files with 64 additions and 8 deletions

View File

@ -2,9 +2,11 @@
# - <https://github.com/francma/wob/blob/master/wob.ini.5.scd>
# - `wob -vv` to see config defaults
#
# the wob services defined here are largely based on those from SXMO.
#
# this should arguably be just a (user) service. nothing actually needs `wob` on the PATH.
#
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.sane.programs.wob;
in
@ -60,14 +62,65 @@ in
Restart = "always";
RestartSec = "20s";
};
path = [ cfg.package ];
script = ''
wobsock="$XDG_RUNTIME_DIR/${cfg.config.sock}"
rm -f "$wobsock" || true
mkfifo "$wobsock" && ${cfg.package}/bin/wob <> "$wobsock"
mkfifo "$wobsock" && wob <> "$wobsock"
# TODO: cleanup should be done in a systemd OnFailure, or OnExit, or whatever
rm -f "$wobsock"
'';
};
services.wob-pulse = {
description = "notify wob when pulseaudio volume changes";
wantedBy = [ "wob.service" ];
serviceConfig = {
Type = "simple";
Restart = "always";
RestartSec = "20s";
};
path = with pkgs; [
# coreutils
gnugrep
gnused
pulseaudio
];
script = ''
volismuted() {
pactl get-sink-mute @DEFAULT_SINK@ | grep -q "Mute: yes"
}
volget() {
if volismuted; then
printf "0"
else
pactl get-sink-volume @DEFAULT_SINK@ | head -n1 | cut -d'/' -f2 | sed 's/ //g' | sed 's/\%//'
fi
}
notify_volume_change() {
vol=$(volget)
if [ "$vol" != "$lastvol" ]; then
printf "%s\n" "$vol" > "$XDG_RUNTIME_DIR/${cfg.config.sock}"
fi
lastvol="$vol"
}
pactl subscribe | while read -r line; do
case "$line" in
"Event 'change' on sink "*)
notify_volume_change
;;
"Event 'change' on source "*)
# microphone volume changed. ignore.
;;
esac
done
'';
};
};
}

View File

@ -181,7 +181,7 @@ in
"playerctl" # for waybar & particularly to have playerctld running
# "mako" # notification daemon
"swaynotificationcenter" # notification daemon
# # "pavucontrol"
"wob" # render volume changes on-screen
# "gnome.gnome-bluetooth" # XXX(2023/05/14): broken
# "gnome.gnome-control-center" # XXX(2023/06/28): depends on webkitgtk4_1
"sway-contrib.grimshot"

View File

@ -269,7 +269,6 @@ in
"sfeed" # want this here so that the user's ~/.sfeed/sfeedrc gets created
# "superd" # make superctl (used by sxmo) be on PATH
# "sway-autoscaler"
"wob" # volume/brightness on-screen display
];
persist.byStore.cryptClearOnBoot = [
@ -628,15 +627,18 @@ in
serviceConfig.RestartSec = "20s";
};
in {
# these are defined here, and started mostly in sxmo_hook_start.sh.
# the ones commented our here are the ones i explicitly no longer use.
# uncommenting them here *won't* cause them to be auto-started.
sxmo_autosuspend = sxmoService "autosuspend";
sxmo_battery_monitor = sxmoService "battery_monitor";
# sxmo_battery_monitor = sxmoService "battery_monitor";
sxmo_desktop_widget = sxmoService "hook_desktop_widget";
sxmo_hook_lisgd = sxmoService "hook_lisgdstart";
sxmo_menumode_toggler = sxmoService "menumode_toggler";
sxmo_modemmonitor = sxmoService "modemmonitor";
sxmo_networkmonitor = sxmoService "networkmonitor";
# sxmo_networkmonitor = sxmoService "networkmonitor";
sxmo_notificationmonitor = sxmoService "notificationmonitor";
sxmo_soundmonitor = sxmoService "soundmonitor";
# sxmo_soundmonitor = sxmoService "soundmonitor";
# sxmo_wob = sxmoService "wob";
sxmo-x11-status = sxmoService "status_xsetroot";

View File

@ -64,7 +64,8 @@ systemctl --user start sxmo_notificationmonitor
# monitor for headphone for statusbar
# this also invokes `wob` whenever the volume is changed
systemctl --user start sxmo_soundmonitor
# don't: my volume monitoring is handled by sway
# systemctl --user start sxmo_soundmonitor
# rotate UI based on physical display angle by default
if [ -n "$SXMO_AUTOROTATE" ]; then