wob: implement as part of sway instead of exclusive to sxmo
This commit is contained in:
parent
43498c62f9
commit
daf046861c
|
@ -2,9 +2,11 @@
|
||||||
# - <https://github.com/francma/wob/blob/master/wob.ini.5.scd>
|
# - <https://github.com/francma/wob/blob/master/wob.ini.5.scd>
|
||||||
# - `wob -vv` to see config defaults
|
# - `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.
|
# this should arguably be just a (user) service. nothing actually needs `wob` on the PATH.
|
||||||
#
|
#
|
||||||
{ config, lib, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.sane.programs.wob;
|
cfg = config.sane.programs.wob;
|
||||||
in
|
in
|
||||||
|
@ -60,14 +62,65 @@ in
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "20s";
|
RestartSec = "20s";
|
||||||
};
|
};
|
||||||
|
path = [ cfg.package ];
|
||||||
script = ''
|
script = ''
|
||||||
wobsock="$XDG_RUNTIME_DIR/${cfg.config.sock}"
|
wobsock="$XDG_RUNTIME_DIR/${cfg.config.sock}"
|
||||||
rm -f "$wobsock" || true
|
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
|
# TODO: cleanup should be done in a systemd OnFailure, or OnExit, or whatever
|
||||||
rm -f "$wobsock"
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ in
|
||||||
"playerctl" # for waybar & particularly to have playerctld running
|
"playerctl" # for waybar & particularly to have playerctld running
|
||||||
# "mako" # notification daemon
|
# "mako" # notification daemon
|
||||||
"swaynotificationcenter" # notification daemon
|
"swaynotificationcenter" # notification daemon
|
||||||
# # "pavucontrol"
|
"wob" # render volume changes on-screen
|
||||||
# "gnome.gnome-bluetooth" # XXX(2023/05/14): broken
|
# "gnome.gnome-bluetooth" # XXX(2023/05/14): broken
|
||||||
# "gnome.gnome-control-center" # XXX(2023/06/28): depends on webkitgtk4_1
|
# "gnome.gnome-control-center" # XXX(2023/06/28): depends on webkitgtk4_1
|
||||||
"sway-contrib.grimshot"
|
"sway-contrib.grimshot"
|
||||||
|
|
|
@ -269,7 +269,6 @@ in
|
||||||
"sfeed" # want this here so that the user's ~/.sfeed/sfeedrc gets created
|
"sfeed" # want this here so that the user's ~/.sfeed/sfeedrc gets created
|
||||||
# "superd" # make superctl (used by sxmo) be on PATH
|
# "superd" # make superctl (used by sxmo) be on PATH
|
||||||
# "sway-autoscaler"
|
# "sway-autoscaler"
|
||||||
"wob" # volume/brightness on-screen display
|
|
||||||
];
|
];
|
||||||
|
|
||||||
persist.byStore.cryptClearOnBoot = [
|
persist.byStore.cryptClearOnBoot = [
|
||||||
|
@ -628,15 +627,18 @@ in
|
||||||
serviceConfig.RestartSec = "20s";
|
serviceConfig.RestartSec = "20s";
|
||||||
};
|
};
|
||||||
in {
|
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_autosuspend = sxmoService "autosuspend";
|
||||||
sxmo_battery_monitor = sxmoService "battery_monitor";
|
# sxmo_battery_monitor = sxmoService "battery_monitor";
|
||||||
sxmo_desktop_widget = sxmoService "hook_desktop_widget";
|
sxmo_desktop_widget = sxmoService "hook_desktop_widget";
|
||||||
sxmo_hook_lisgd = sxmoService "hook_lisgdstart";
|
sxmo_hook_lisgd = sxmoService "hook_lisgdstart";
|
||||||
sxmo_menumode_toggler = sxmoService "menumode_toggler";
|
sxmo_menumode_toggler = sxmoService "menumode_toggler";
|
||||||
sxmo_modemmonitor = sxmoService "modemmonitor";
|
sxmo_modemmonitor = sxmoService "modemmonitor";
|
||||||
sxmo_networkmonitor = sxmoService "networkmonitor";
|
# sxmo_networkmonitor = sxmoService "networkmonitor";
|
||||||
sxmo_notificationmonitor = sxmoService "notificationmonitor";
|
sxmo_notificationmonitor = sxmoService "notificationmonitor";
|
||||||
sxmo_soundmonitor = sxmoService "soundmonitor";
|
# sxmo_soundmonitor = sxmoService "soundmonitor";
|
||||||
# sxmo_wob = sxmoService "wob";
|
# sxmo_wob = sxmoService "wob";
|
||||||
sxmo-x11-status = sxmoService "status_xsetroot";
|
sxmo-x11-status = sxmoService "status_xsetroot";
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ systemctl --user start sxmo_notificationmonitor
|
||||||
|
|
||||||
# monitor for headphone for statusbar
|
# monitor for headphone for statusbar
|
||||||
# this also invokes `wob` whenever the volume is changed
|
# 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
|
# rotate UI based on physical display angle by default
|
||||||
if [ -n "$SXMO_AUTOROTATE" ]; then
|
if [ -n "$SXMO_AUTOROTATE" ]; then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user