Use mako instead of wob for volume and brightness

This commit is contained in:
Kiana Sheibani 2024-02-05 12:55:48 -05:00
parent f867311bb7
commit 524bffc068
2 changed files with 38 additions and 21 deletions

View file

@ -60,11 +60,6 @@ in {
};
startup = map (x: { command = x; }) [
# Make wob channels
''mkfifo $XDG_RUNTIME_DIR/wob_volume.sock && tail -f $XDG_RUNTIME_DIR/wob_volume.sock \
| wob -c ~/.config/wob/volume.ini''
''mkfifo $XDG_RUNTIME_DIR/wob_brightness.sock && tail -f $XDG_RUNTIME_DIR/wob_brightness.sock \
| wob -c ~/.config/wob/brightness.ini''
''swayidle timeout 120 'swaylock -f --grace=180' \
timeout 600 'systemctl suspend' \
before-sleep 'swaylock -f' ''
@ -73,11 +68,17 @@ in {
];
keybindings = let
# Volume using pamixer and wob
audio-disp = ''pamixer --get-volume > $XDG_RUNTIME_DIR/wob_volume.sock'';
multimedia = summary: app: value:
''
notify-send ${summary} -c multimedia -a ${app} \
$(makoctl list | jq -r 'first(.data[][]|select(.category.data=="multimedia")|.id.data|["-r",.])[]') \
-h INT:value:$(${value})
'';
# Volume using pamixer
audio-disp = multimedia "Volume" "pamixer" "pamixer --get-volume";
audio = cmd: "exec pamixer ${cmd} && ${audio-disp}";
# Brightness using brightnessctl and wob
brightness-disp = ''brightnessctl -e -m | cut -d "," -f4 | tr -d "%" > $XDG_RUNTIME_DIR/wob_brightness.sock'';
# Brightness using brightnessctl
brightness-disp = multimedia "Brightness" "brightnessctl" ''brightnessctl -e -m | cut -d "," -f4 | tr -d "%"'';
brightness = x: "exec brightnessctl -e set ${x} && ${brightness-disp}";
# Play controls using playerctl
playerctl = cmd: "exec playerctl ${cmd}";
@ -101,10 +102,10 @@ in {
select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" ${filename}'';
# Special XF86 key bindings
"XF86AudioRaiseVolume" = audio "-ui 2";
"XF86AudioLowerVolume" = audio "-ud 2";
"Shift+XF86AudioRaiseVolume" = audio "-ui 2 --allow-boost";
"Shift+XF86AudioLowerVolume" = audio "-ud 2 --allow-boost";
"XF86AudioRaiseVolume" = audio "-i 2";
"XF86AudioLowerVolume" = audio "-d 2";
"Shift+XF86AudioRaiseVolume" = audio "-i 2 --allow-boost";
"Shift+XF86AudioLowerVolume" = audio "-d 2 --allow-boost";
"XF86AudioMute" = ''exec pamixer --toggle-mute'';
"XF86AudioMicMute" = ''exec pactl set-source-mute @DEFAULT_SOURCE@ toggle'';
"XF86MonBrightnessDown" = brightness "4%-";

View file

@ -1,14 +1,8 @@
{ pkgs, config, ... }:
{
home.packages = with pkgs; [ swaylock-effects wob ];
home.packages = [ pkgs.swaylock-effects ];
xdg.configFile = {
"wob/volume.ini".text = "";
"wob/brightness.ini".text = ''
border_color = FFFF00FF
bar_color = FFFF00FF
'';
"swaylock/config".text = ''
ignore-empty-password
fade-in=0.3
@ -70,7 +64,7 @@
borderSize = 2;
borderColor = "#7bc5e4";
borderRadius = 5;
defaultTimeout = 10000;
progressColor = "source #4e90ad";
extraConfig =
''
@ -78,15 +72,18 @@
format=<i>%s</i>\n%b
background-color=#111111c0
border-color=#787c99
progress-color=source #474f6f
border-size=1
[urgency=high]
background-color=#1e0909d0
border-color=#ce7284
progress-color=source #bc5469
border-size=3
default-timeout=0
ignore-timeout=1
[app-name=discord]
format=<b>%s</b>\n\n%b
border-color=#7da6ff
@ -94,6 +91,25 @@
[app-name=discordcanary]
format=<b>%s</b>\n\n%b
border-color=#7da6ff
[category=multimedia]
anchor=center
width=430
font=JetBrainsMono Nerd Font 13
format=<i>%s</i>
border-size=1
default-timeout=2000
[app-name=pamixer]
background-color=#111111c0
border-color=#787c99
progress-color=source #474f6f
[app-name=brightnessctl]
background-color=#111111c0
border-color=#ffea63
progress-color=source #a08348
'';
};
}