diff --git a/pkgs/scripts/assets/audio-sink-decrease.svg b/pkgs/scripts/assets/audio-sink-decrease.svg
new file mode 100644
index 0000000..f94fe44
--- /dev/null
+++ b/pkgs/scripts/assets/audio-sink-decrease.svg
@@ -0,0 +1,62 @@
+
+
+
diff --git a/pkgs/scripts/assets/audio-sink-default.svg b/pkgs/scripts/assets/audio-sink-default.svg
new file mode 120000
index 0000000..d48faf9
--- /dev/null
+++ b/pkgs/scripts/assets/audio-sink-default.svg
@@ -0,0 +1 @@
+audio-sink-decrease.svg
\ No newline at end of file
diff --git a/pkgs/scripts/assets/audio-sink-increase.svg b/pkgs/scripts/assets/audio-sink-increase.svg
new file mode 100644
index 0000000..c3d9ac4
--- /dev/null
+++ b/pkgs/scripts/assets/audio-sink-increase.svg
@@ -0,0 +1,76 @@
+
+
+
diff --git a/pkgs/scripts/assets/audio-sink-mute.svg b/pkgs/scripts/assets/audio-sink-mute.svg
new file mode 100644
index 0000000..d7ccc03
--- /dev/null
+++ b/pkgs/scripts/assets/audio-sink-mute.svg
@@ -0,0 +1,77 @@
+
+
+
diff --git a/pkgs/scripts/assets/audio-source-decrease.svg b/pkgs/scripts/assets/audio-source-decrease.svg
new file mode 120000
index 0000000..cfebd37
--- /dev/null
+++ b/pkgs/scripts/assets/audio-source-decrease.svg
@@ -0,0 +1 @@
+audio-source-default.svg
\ No newline at end of file
diff --git a/pkgs/scripts/assets/audio-source-default.svg b/pkgs/scripts/assets/audio-source-default.svg
new file mode 100644
index 0000000..a0f2f07
--- /dev/null
+++ b/pkgs/scripts/assets/audio-source-default.svg
@@ -0,0 +1,102 @@
+
+
+
diff --git a/pkgs/scripts/assets/audio-source-increase.svg b/pkgs/scripts/assets/audio-source-increase.svg
new file mode 120000
index 0000000..cfebd37
--- /dev/null
+++ b/pkgs/scripts/assets/audio-source-increase.svg
@@ -0,0 +1 @@
+audio-source-default.svg
\ No newline at end of file
diff --git a/pkgs/scripts/assets/audio-source-mute.svg b/pkgs/scripts/assets/audio-source-mute.svg
new file mode 100644
index 0000000..5af107a
--- /dev/null
+++ b/pkgs/scripts/assets/audio-source-mute.svg
@@ -0,0 +1,129 @@
+
+
+
diff --git a/pkgs/scripts/default.nix b/pkgs/scripts/default.nix
index 687cd14..6b70971 100644
--- a/pkgs/scripts/default.nix
+++ b/pkgs/scripts/default.nix
@@ -3,5 +3,6 @@ _final: prev: {
screenshot-area = prev.callPackage ./screenshot-area.nix {};
screenshot-area-scan-qr = prev.callPackage ./screenshot-area-scan-qr.nix {};
screenshot-screen = prev.callPackage ./screenshot-screen.nix {};
+ volume = prev.callPackage ./volume.nix {};
};
}
diff --git a/pkgs/scripts/screenshot-area-scan-qr.nix b/pkgs/scripts/screenshot-area-scan-qr.nix
index cbdafc5..c79be67 100644
--- a/pkgs/scripts/screenshot-area-scan-qr.nix
+++ b/pkgs/scripts/screenshot-area-scan-qr.nix
@@ -36,7 +36,7 @@ writeShellApplication {
${xclip}/bin/xclip -selection clipboard <<< "$DATA"
${libnotify}/bin/notify-send \
"š QR Code scan" "ā
$N codes detected\nš copied ''${#DATA} bytes" \
- --hint="string:image-path:"${./assets/qr-scan.png} \
+ --hint="string:image-path:"${./assets}/qr-scan.png \
--hint="string:wired-tag:screenshot-$date" \
|| true
else
@@ -44,14 +44,14 @@ writeShellApplication {
"4")
${libnotify}/bin/notify-send \
"š QR Code scan" "ā 0 codes detected" \
- --hint="string:image-path:"${./assets/qr-scan.png} \
+ --hint="string:image-path:"${./assets}/qr-scan.png \
--hint="string:wired-tag:screenshot-$date" \
|| true
;;
*)
${libnotify}/bin/notify-send \
"š QR Code scan" "ā Error while processing image: zbarimg exited with code $?" \
- --hint="string:image-path:"${./assets/qr-scan.png} \
+ --hint="string:image-path:"${./assets}/qr-scan.png \
--hint="string:wired-tag:screenshot-$date" \
|| true
;;
diff --git a/pkgs/scripts/volume.nix b/pkgs/scripts/volume.nix
new file mode 100644
index 0000000..4990d1b
--- /dev/null
+++ b/pkgs/scripts/volume.nix
@@ -0,0 +1,48 @@
+{
+ writeShellApplication,
+ bc,
+ libnotify,
+ wireplumber,
+}:
+writeShellApplication {
+ name = "volume";
+ text = ''
+ set -euo pipefail
+
+ ${wireplumber}/bin/wpctl "$1" "$2" "$3"
+ current_volume=$(${wireplumber}/bin/wpctl get-volume "$2")
+ case "''${2,,}" in
+ *"source"*) type=source ;;
+ *) type=sink ;;
+ esac
+
+ case "$3" in
+ *"%+") image=${./assets}/audio-"$type"-increase.svg ;;
+ *"%-") image=${./assets}/audio-"$type"-decrease.svg ;;
+ *) image=${./assets}/audio-"$type"-default.svg ;;
+ esac
+
+ value=$(grep -o '[0-9]\.[0-9]*' <<< "$current_volume" || echo 0.0)
+ value=$(${bc}/bin/bc <<< "scale=0; $value*100/1")
+ if grep -q MUTED <<< "$current_volume"; then
+ image=${./assets}/audio-"$type"-mute.svg
+ fi
+
+ if [[ "$value" -gt 100 ]]; then
+ note=volume-overdrive
+ indicator_value=$((value - 100))
+ else
+ note=volume
+ indicator_value="$value"
+ fi
+
+ ${libnotify}/bin/notify-send \
+ "Volume" "$value%" \
+ --hint=string:image-path:"$image" \
+ --hint=int:value:"$indicator_value" \
+ --hint="string:wired-tag:indicator" \
+ --hint="string:wired-note:$note" \
+ --expire-time=1000 \
+ || true
+ '';
+}
diff --git a/users/myuser/graphical/i3.nix b/users/myuser/graphical/i3.nix
index f96a6b6..2a9e050 100644
--- a/users/myuser/graphical/i3.nix
+++ b/users/myuser/graphical/i3.nix
@@ -66,13 +66,10 @@ in {
keybindings =
{
- "XF86AudioRaiseVolume" = "exec --no-startup-id wpctl set-sink-volume @DEFAULT_SINK@ +5%";
- "XF86AudioLowerVolume" = "exec --no-startup-id wpctl set-sink-volume @DEFAULT_SINK@ -5%";
- "XF86AudioMute" = "exec --no-startup-id wpctl set-sink-mute @DEFAULT_SINK@ toggle";
- "XF86AudioMicMute" = "exec --no-startup-id wpctl set-source-mute @DEFAULT_SOURCE@ toggle";
-
- #"Print" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy area";
- #"${mod}+Print" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot save area";
+ "XF86AudioRaiseVolume" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-volume @DEFAULT_AUDIO_SINK@ 5%+";
+ "XF86AudioLowerVolume" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-volume @DEFAULT_AUDIO_SINK@ 5%-";
+ "XF86AudioMute" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-mute @DEFAULT_AUDIO_SINK@ toggle";
+ "XF86AudioMicMute" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
}
# // optionalAttrs useBacklight {
# "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5";
diff --git a/users/myuser/graphical/wired-notify.nix b/users/myuser/graphical/wired-notify.nix
index 307663c..7bedc7b 100644
--- a/users/myuser/graphical/wired-notify.nix
+++ b/users/myuser/graphical/wired-notify.nix
@@ -547,6 +547,7 @@
(Not (Or [
(struct "Note" "brightness")
(struct "Note" "volume")
+ (struct "Note" "volume-overdrive")
]))
];
}
@@ -576,11 +577,29 @@
];
}
# text extra
- {}
+ {
+ text = "%b";
+ }
# progress extra
{
fill_color = colors.base0B;
})
+ (mkIndicatorValue "indicator" "volume_overdrive" "hint" {
+ render_criteria = [
+ (And [
+ (struct "Note" "volume-overdrive")
+ ])
+ ];
+ }
+ # text extra
+ {
+ text = "%b";
+ }
+ # progress extra
+ {
+ background_color = colors.base0B;
+ fill_color = colors.base0A;
+ })
]);
});
};