i3status updates via signals

This commit is contained in:
krizej 2024-09-27 22:56:36 +02:00
parent cce24cbd95
commit a2c5b7fa49

View file

@ -92,11 +92,17 @@ in {
] ]
++ optionals config.chuj.stuff.mpd.enable [ ++ optionals config.chuj.stuff.mpd.enable [
{ command = "${pkgs.writeShellScriptBin "mpdstatus" '' { command = "${pkgs.writeShellScriptBin "mpdstatus" ''
trap "echo SIG" USR1 EXIT
while true; do while true; do
sleep 1 &
wait
status=$(mpc status | sed -n 2p | cut -d' ' -f1) status=$(mpc status | sed -n 2p | cut -d' ' -f1)
title=$(basename "$(mpc current -f '%file%')" .mp3) title=$(basename "$(mpc current -f '%file%')" .mp3)
echo "$status $title" > /tmp/i3-mpd-status-stuff echo "$status $title" > /tmp/i3-mpd-status-stuff
sleep 1 echo update!!
done done
''}/bin/mpdstatus &"; notification = false; } ''}/bin/mpdstatus &"; notification = false; }
]; ];
@ -120,6 +126,9 @@ in {
mod = modifier; mod = modifier;
execns = "exec --no-startup-id"; execns = "exec --no-startup-id";
cmd_and_center = cmd: "${execns} i3-msg '${cmd}' && i3custom-center-mouse-on-focus"; cmd_and_center = cmd: "${execns} i3-msg '${cmd}' && i3custom-center-mouse-on-focus";
killall = "${pkgs.killall}/bin/killall";
update_mpdstatus = "${killall} -USR1 mpdstatus && sleep 0.05"; # hack as fack xd
update_i3status = "${killall} -USR1 i3status";
in mergeAttrs { in mergeAttrs {
# Program keybinds # Program keybinds
"${mod}+Return" = ''${execns} ${if config.chuj.stuff.alacritty.enable then "alacritty" else "i3-sensible-terminal"}''; "${mod}+Return" = ''${execns} ${if config.chuj.stuff.alacritty.enable then "alacritty" else "i3-sensible-terminal"}'';
@ -129,9 +138,9 @@ in {
"--release ${mod}+k" = "${execns} xkill"; "--release ${mod}+k" = "${execns} xkill";
# Volume control # Volume control
"Ctrl+F9" = "${execns} pamixer --toggle-mute"; "Ctrl+F9" = "${execns} pamixer --toggle-mute && ${update_i3status}";
"Ctrl+F10" = "${execns} pamixer --decrease 5"; "Ctrl+F10" = "${execns} pamixer --decrease 5 && ${update_i3status}";
"Ctrl+F11" = "${execns} pamixer --increase 5"; "Ctrl+F11" = "${execns} pamixer --increase 5 && ${update_i3status}";
# General i3 keybindings # General i3 keybindings
"${mod}+f" = cmd_and_center "fullscreen toggle"; "${mod}+f" = cmd_and_center "fullscreen toggle";
@ -181,12 +190,12 @@ in {
"${mod}+Shift+0" = cmd_and_center "move container to workspace number 10"; "${mod}+Shift+0" = cmd_and_center "move container to workspace number 10";
} (optionalAttrs config.chuj.stuff.mpd.enable { } (optionalAttrs config.chuj.stuff.mpd.enable {
# MPD controls # MPD controls
"Ctrl+F5" = "exec mpdfdial.sh"; "Ctrl+F5" = "exec mpdfdial.sh && ${update_mpdstatus} && ${update_i3status}";
"Ctrl+F6" = "exec mpc prev"; "Ctrl+F6" = "exec mpc prev && ${update_mpdstatus} && ${update_i3status}";
"Ctrl+F7" = "exec mpc toggle"; "Ctrl+F7" = "exec mpc toggle && ${update_mpdstatus} && ${update_i3status}";
"Ctrl+F8" = "exec mpc next"; "Ctrl+F8" = "exec mpc next && ${update_mpdstatus} && ${update_i3status}";
"Ctrl+Shift+F6" = "exec mpc seek -3"; "Ctrl+Shift+F6" = "exec mpc seek -3";
"Ctrl+Shift+F7" = "exec mpc clear"; "Ctrl+Shift+F7" = "exec mpc clear && ${update_mpdstatus} && ${update_i3status}";
"Ctrl+Shift+F8" = "exec mpc seek +3"; "Ctrl+Shift+F8" = "exec mpc seek +3";
"Ctrl+Shift+F10" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420''; "Ctrl+Shift+F10" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420'';
"Ctrl+Shift+F11" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420''; "Ctrl+Shift+F11" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420'';