summaryrefslogtreecommitdiffstats
path: root/.local/bin/mixer-set
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x.local/bin/mixer-set118
1 files changed, 57 insertions, 61 deletions
diff --git a/.local/bin/mixer-set b/.local/bin/mixer-set
index c5911bb..2f905ca 100755
--- a/.local/bin/mixer-set
+++ b/.local/bin/mixer-set
@@ -4,6 +4,18 @@ use strict;
use warnings;
use Term::ANSIColor;
use Capture::Tiny qw(capture);
+use Sys::Hostname qw(hostname);
+
+sub notify
+{
+ my ($str) = @_;
+
+ my $pid = fork();
+ if (not $pid) {
+ exec('/usr/local/bin/herbe', $str);
+ }
+ return;
+};
sub main {
my $argc = $#ARGV + 1;
@@ -21,33 +33,36 @@ 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}'";
+ }
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',
- '-h',
- 'int:value:' . $curr_vol,
- '-u',
- 'low',
- '-t',
- '1000',
- 'mixer-set',
- '墳 Volume'
- );
- system('kill -68 $(pidof dwmblocks)');
+ notify('[vol] ' . $curr_vol);
exit;
}
elsif ($ARGV[0] eq "toggle") {
@@ -58,57 +73,38 @@ sub main {
open(my $fh, '>:encoding(UTF-8)', $tmp_file);
print $fh $curr_vol;
close($fh);
- capture {
- system(
- '/usr/sbin/mixer',
- 'vol',
- '0'
- );
- };
- system(
- '/usr/local/bin/notify-send',
- '-u',
- 'low',
- '-t',
- '1750',
- 'mixer-set',
- '婢 Volume muted'
- );
- system('kill -68 $(pidof dwmblocks)');
+ 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'
+ );
+ };
+ }
+ notify('[vol] muted');
}
else {
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',
- '-h',
- 'int:value:' . $curr_vol,
- '-u',
- 'low',
- '-t',
- '1750',
- 'mixer-set',
- $icon . ' Volume restored'
- );
- system('kill -68 $(pidof dwmblocks)');
+ notify('[vol] ' . $curr_vol);
}
exit;
}