summaryrefslogtreecommitdiffstats
path: root/local/.bin/hornet/volume
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-10-08 12:09:20 -0400
committerJesse Luehrs <doy@tozt.net>2023-10-08 12:59:10 -0400
commit49570c8dd03448240897b37b68567352b790f16f (patch)
tree6c192a52046d5d0dd1b84a838befd8e777cfeafb /local/.bin/hornet/volume
parent66939c71da756c1d9e07a88a4a8ea2a018650060 (diff)
downloadconf-49570c8dd03448240897b37b68567352b790f16f.tar.gz
conf-49570c8dd03448240897b37b68567352b790f16f.zip
convert to stow
Diffstat (limited to 'local/.bin/hornet/volume')
-rwxr-xr-xlocal/.bin/hornet/volume45
1 files changed, 45 insertions, 0 deletions
diff --git a/local/.bin/hornet/volume b/local/.bin/hornet/volume
new file mode 100755
index 0000000..668c1b1
--- /dev/null
+++ b/local/.bin/hornet/volume
@@ -0,0 +1,45 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.014;
+
+chomp(my $sink=`pactl get-default-sink`);
+
+sub get {
+ if (`pactl get-sink-mute $sink` =~ /Mute: yes/) {
+ 'mute'
+ }
+ else {
+ (`pactl get-sink-volume $sink` =~ /(\d+)%/)[0]
+ }
+}
+
+if ($ARGV[0] eq 'get') {
+ say get;
+}
+elsif ($ARGV[0] eq 'up') {
+ my $get = get;
+ system("pactl set-sink-mute $sink 0");
+ if ($get eq 'mute') {
+ exit;
+ }
+ elsif ($get <= 90) {
+ system("pactl set-sink-volume $sink +10%");
+ }
+ elsif ($get < 100) {
+ system("pactl set-sink-volume $sink 100%");
+ }
+}
+elsif ($ARGV[0] eq 'down') {
+ my $get = get;
+ if ($get eq 'mute') {
+ exit;
+ }
+ system("pactl set-sink-volume $sink -10%");
+}
+elsif ($ARGV[0] eq 'mute') {
+ system("pactl set-sink-mute $sink toggle")
+}
+else {
+ die "unknown command '$ARGV[0]'";
+}