summaryrefslogtreecommitdiffstats
path: root/.local/bin/mixer-set
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2025-07-07 10:46:28 +0200
committerJoe <rbo@gmx.us>2025-07-07 10:46:28 +0200
commit2a432dacede9080583b4e8a91d3eb736fe636629 (patch)
treee19adda6b360de3a11ac3e43bb4d726a1e491124 /.local/bin/mixer-set
parentup (diff)
downloaddotfiles-bsd-2a432dacede9080583b4e8a91d3eb736fe636629.tar.gz
dotfiles-bsd-2a432dacede9080583b4e8a91d3eb736fe636629.tar.bz2
dotfiles-bsd-2a432dacede9080583b4e8a91d3eb736fe636629.tar.xz
dotfiles-bsd-2a432dacede9080583b4e8a91d3eb736fe636629.tar.zst
dotfiles-bsd-2a432dacede9080583b4e8a91d3eb736fe636629.zip
up
Diffstat (limited to '.local/bin/mixer-set')
-rwxr-xr-x.local/bin/mixer-set86
1 files changed, 53 insertions, 33 deletions
diff --git a/.local/bin/mixer-set b/.local/bin/mixer-set
index c5911bb..9963c91 100755
--- a/.local/bin/mixer-set
+++ b/.local/bin/mixer-set
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Term::ANSIColor;
use Capture::Tiny qw(capture);
+use Sys::Hostname qw(hostname);
sub main {
my $argc = $#ARGV + 1;
@@ -21,23 +22,41 @@ sub main {
print "Too many arguments, only one needed\n";
exit 2;
}
+ my $host = hostname();
my $curr_vol = 0;
my $curr_vol_cmd = "/usr/sbin/mixer vol | /usr/bin/awk -F ':' '{print \$2}'";
+ if ($host eq "po-rbo.ln.ysosecure.com") {
+ $curr_vol_cmd = "/usr/bin/pactl get-sink-volume \@DEFAULT_SINK\@ | /usr/bin/awk '{print \$5}'";
+ }
+ my $ns = '/usr/local/bin/notify-send';
+ if (hostname() eq "po-rbo.ln.ysosecure.com") {
+ $ns = '/usr/bin/notify-send';
+ }
if ($ARGV[0] eq "lower" || $ARGV[0] eq "raise") {
if ($ARGV[0] eq "lower") {
- capture {
- system('/usr/sbin/mixer', 'vol', '-5');
- };
+ if ($host eq "po-rbo.ln.ysosecure.com") {
+ system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', '-5%');
+ }
+ else {
+ capture {
+ system('/usr/sbin/mixer', 'vol', '-5');
+ };
+ }
}
else {
- capture {
- system('/usr/sbin/mixer', 'vol', '+5');
- };
+ if ($host eq "po-rbo.ln.ysosecure.com") {
+ system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', '+5%');
+ }
+ else {
+ capture {
+ system('/usr/sbin/mixer', 'vol', '+5');
+ };
+ }
}
$curr_vol = `$curr_vol_cmd`;
chomp $curr_vol;
system(
- '/usr/local/bin/notify-send',
+ $ns,
'-h',
'int:value:' . $curr_vol,
'-u',
@@ -45,7 +64,7 @@ sub main {
'-t',
'1000',
'mixer-set',
- '墳 Volume'
+ ' volume'
);
system('kill -68 $(pidof dwmblocks)');
exit;
@@ -58,21 +77,26 @@ sub main {
open(my $fh, '>:encoding(UTF-8)', $tmp_file);
print $fh $curr_vol;
close($fh);
- capture {
- system(
- '/usr/sbin/mixer',
- 'vol',
- '0'
- );
- };
+ if ($host eq "po-rbo.ln.ysosecure.com") {
+ system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', '0%');
+ }
+ else {
+ capture {
+ system(
+ '/usr/sbin/mixer',
+ 'vol',
+ '0'
+ );
+ };
+ }
system(
- '/usr/local/bin/notify-send',
+ $ns,
'-u',
'low',
'-t',
'1750',
'mixer-set',
- '婢 Volume muted'
+ ' muted'
);
system('kill -68 $(pidof dwmblocks)');
}
@@ -80,25 +104,21 @@ sub main {
open(my $fh, '<:encoding(UTF-8)', $tmp_file);
$curr_vol = <$fh>;
close($fh);
- capture {
- system(
- '/usr/sbin/mixer',
- 'vol',
- $curr_vol
- );
- };
- my $icon;
- if ($curr_vol <= 33) {
- $icon = '奄 ';
- }
- elsif ($curr_vol <= 66) {
- $icon = '奔 ';
+ if ($host eq "po-rbo.ln.ysosecure.com") {
+ chomp $curr_vol;
+ system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', $curr_vol);
}
else {
- $icon = '墳 ';
+ capture {
+ system(
+ '/usr/sbin/mixer',
+ 'vol',
+ $curr_vol
+ );
+ };
}
system(
- '/usr/local/bin/notify-send',
+ $ns,
'-h',
'int:value:' . $curr_vol,
'-u',
@@ -106,7 +126,7 @@ sub main {
'-t',
'1750',
'mixer-set',
- $icon . ' Volume restored'
+ ' restored'
);
system('kill -68 $(pidof dwmblocks)');
}