At least I can mute which was my very first need. It looks like it takes an absolute value as input. Ideally, for increase/decrease I would like to store somewhere the previous value and then changed it. The same for mute/unmute but I it’s a start
Yes, I found that.
The thing is that is manual.
setvolume binary does not return current volume value, just prints it (checked the code), always returns 0.
So I cannot generalize this easily. Should write a script that parses setvolume output to get the value from there.
But I think I prefer to experiment with setvolume itself (or clone it) and add all things I need there, like mute/unmute, increase/decrease volume. Code looks straight forward
I wrote a small tool a long time ago to do some of this stuff because the regular setvolume command was lacking in features. I’ve uploaded it if you want to use it or look at it. Unzip, run ‘cmake .’ and then ‘make’
Update:
Crashes only when I am passing no parameters.
Otherwise I used succesfully mute/unmute
This is my immediate need. Thanks a lot, really appreciated @Lrrr !
Update 2:
Everything works like a charm: adjust, toggle, volume!
Exactly what I was looking for!
Looks like I found the only code flow that crash: passing no option
#!yab
if peek(“argument”) <> 1 then
usage()
end
endif
arg$=peek$(“argument”)
arg$=lower$(arg$)
if arg$="help"then
usage()
end
endif
if arg$=“mute” system(“setvolume > /tmp/currentvolume”)
a=open (“/tmp/currentvolume”,“r”)
for x=1 to 9
input #a a$
if (x= 3) currentvolume$ = a$
if x=6 min$=left$(a$,len(a$)-1)
if x=9 max$=left$(a$,len(a$)-1)
next
if arg$=“mute” then
system(“setvolume “+min$ +”>/tmp/nul”)
end
endif
if arg$=“restore” then
system(“setvolume “+currentvolume$ +”> /tmp/nul”)
beep
end
endif
if val(arg$)=0 end
cv=val(currentvolume$)
if right$(arg$,1)<>“m” then
cv=cv+val(arg$)
else
cv=cv-val(arg$)
endif
if (cv > val (min$) and cv<val(max$) )then
sub usage()
print “vol.sh controls the system volume from the command line, or a script.”
print
print
print “usage:”
print “vol.sh [option]”
print
print " Options are :"
print
print " mute Mutes the volume."
print
print " restore Restores a muted volume."
print
print " number ie 1,10 etc. increased the volume"
print
print " number with “+chr$(34)+“m”+chr$(34)+” appended ie 1m, 10m etc. decreases the volume"
print
print " help prints this information."
end sub
save as vol.sh and set it to executable… requires yab
That’s @Lrrr 's own weather app, he hasn’t released it yet, but you can compile it yourself, i personally find it quite usable already, i have it installed on both 32 bit & 64 bit haiku, you can build it for 32 bit with a minor change.