From ff3198ee65f1c217d51be133816a76c0648afcd7 Mon Sep 17 00:00:00 2001 From: brustybee Date: Sat, 7 Mar 2026 05:04:20 +0530 Subject: Add waybar and scripts --- common/modules/mango/scripts.nix | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 common/modules/mango/scripts.nix (limited to 'common/modules/mango/scripts.nix') diff --git a/common/modules/mango/scripts.nix b/common/modules/mango/scripts.nix new file mode 100644 index 0000000..b3de75d --- /dev/null +++ b/common/modules/mango/scripts.nix @@ -0,0 +1,77 @@ +{ pkgs, ... }: +let + # CHANGED: writeShellScript -> writeShellScriptBin + volume-control = pkgs.writeShellScriptBin "volume-control" '' + TAG="audio-volume" + + function get_vol { + ${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}' + } + + case $1 in + up) ${pkgs.wireplumber}/bin/wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+ ;; + down) ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;; + mute) ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; + esac + + vol=$(get_vol) + is_muted=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep "MUTED") + + if [ -n "$is_muted" ]; then + ${pkgs.dunst}/bin/dunstify -a "Volume" -u low \ + -h string:x-canonical-private-synchronous:$TAG \ + "Volume: Muted" + else + ${pkgs.dunst}/bin/dunstify -a "Volume" -u low \ + -h string:x-canonical-private-synchronous:$TAG \ + -h int:value:"$vol" \ + "Volume: $vol%" + fi + ''; + + # CHANGED: writeShellScript -> writeShellScriptBin + brightness-control = pkgs.writeShellScriptBin "brightness-control" '' + TAG="screen-brightness" + + case $1 in + up) ${pkgs.brightnessctl}/bin/brightnessctl set +5% ;; + down) ${pkgs.brightnessctl}/bin/brightnessctl set 5%- ;; + esac + + # Get current percentage + current=$(${pkgs.brightnessctl}/bin/brightnessctl info | grep -oP '\(\K[0-9]+(?=%\))') + + ${pkgs.dunst}/bin/dunstify -a "Brightness" -u low \ + -h string:x-canonical-private-synchronous:$TAG \ + -h int:value:"$current" \ + "Brightness: $current%" + ''; + + # CHANGED: writeShellScript -> writeShellScriptBin + mic-control = pkgs.writeShellScriptBin "mic-control" '' + TAG="audio-mic" + + case $1 in + toggle) ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;; + esac + + is_muted=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep "MUTED") + + if [ -n "$is_muted" ]; then + ${pkgs.dunst}/bin/dunstify -a "Microphone" -u low \ + -h string:x-canonical-private-synchronous:$TAG \ + "Microphone: Muted" + else + ${pkgs.dunst}/bin/dunstify -a "Microphone" -u low \ + -h string:x-canonical-private-synchronous:$TAG \ + "Microphone: On" + fi + ''; +in +{ + home.packages = [ + volume-control + brightness-control + mic-control + ]; +} -- cgit v1.3.1