Tray Volume selector - Updated Mar 2007!
Finally got around to testing in Puppy 2.14. Respect balance doesn't seem to be working properly. If the balance control is off center either left or right just a little in the mixer, it sends the balance control all that way fully. This happen when you move the mouse over the tray icon for mini-volume. It is probably not a problem with the mixers because I tried two different mixers and they reacted the same.
One was your nice new mixer and the other was xtmix.
In farther testing I tried kmix, same thing on the sound being sent fully to one channel if balance was off center. When running kmix fully from its own tray icon no problem.
Good Luck, Kal
One was your nice new mixer and the other was xtmix.
In farther testing I tried kmix, same thing on the sound being sent fully to one channel if balance was off center. When running kmix fully from its own tray icon no problem.
Good Luck, Kal
Version 0.7
Download it from here:
http://www.murga-linux.com/puppy/viewto ... 1724#51724
This version is designed to work better with the pvolume-mixer or any other external mixer.
Changelog:
2007-03-03 - 19:20 (version 0.7)
- Fixed a bug calculating balance
Download it from here:
http://www.murga-linux.com/puppy/viewto ... 1724#51724
This version is designed to work better with the pvolume-mixer or any other external mixer.
Changelog:
2007-03-03 - 19:20 (version 0.7)
- Fixed a bug calculating balance
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to
New Upgrades - OK
Excellent, now we're cooking. Thanks for uploading the new ones. Yes they fix it. Very nice additions to the mixer too.
Very Good, Thanks again, Kal
Very Good, Thanks again, Kal
Re: New Upgrades - OK
Thank you for reporting it. I new about the problem but I thought the fix was in 0.6.Kal wrote:Thanks again, Kal
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to
I found that since I use the middle button for mute, it is more efficient to get rid of the right click menu, and just bring up a mixer with the right click.
If anyone else is interested, here is the code:
In mini-volume.tcl:
Comment out this to get rid of the menu:
#bind .b <ButtonPress-3> { menu:show %W }
Add something like this to bring up a mixer on right click:
bind .b <ButtonPress-3> { exec xtmix -geometry -0-23 }
You'll have to figure out the appropriate command - I have a very old Puppy, so my mixer is xtmix. that geometry entry puts the mixer at the bottom right of my screen. Depending on the height of your taskbar you might need to change the -23. If you have a taskbar at the top of the screen you would use -0+23 instead.
Add this to get the middle button mute:
bind .b <ButtonPress-2> { setvolume 0 }
Something might actually be slightly different. The latest version of mini-volume.tcl doesn't work in my old puppy, so I'm using an older version that I've hacked most of the recent functionality into. It is actually better in one way:
In a standard puppy if you right click->mute then there is no unmute function to restore the volume to it's previous level. In mine, I can roll the wheel over the icon and the volume changes, starting from the level it was at before it was muted. I think the normal behaviour is deliberate, and I think it would make the most sense, but only if there was a working "unmute" function.
---------------------
The only problem is that if the volume tooltip is there when I right-click, it stays there (but is blank) until the mixer is closed.
If anyone else is interested, here is the code:
In mini-volume.tcl:
Comment out this to get rid of the menu:
#bind .b <ButtonPress-3> { menu:show %W }
Add something like this to bring up a mixer on right click:
bind .b <ButtonPress-3> { exec xtmix -geometry -0-23 }
You'll have to figure out the appropriate command - I have a very old Puppy, so my mixer is xtmix. that geometry entry puts the mixer at the bottom right of my screen. Depending on the height of your taskbar you might need to change the -23. If you have a taskbar at the top of the screen you would use -0+23 instead.
Add this to get the middle button mute:
bind .b <ButtonPress-2> { setvolume 0 }
Something might actually be slightly different. The latest version of mini-volume.tcl doesn't work in my old puppy, so I'm using an older version that I've hacked most of the recent functionality into. It is actually better in one way:
In a standard puppy if you right click->mute then there is no unmute function to restore the volume to it's previous level. In mine, I can roll the wheel over the icon and the volume changes, starting from the level it was at before it was muted. I think the normal behaviour is deliberate, and I think it would make the most sense, but only if there was a working "unmute" function.
---------------------
The only problem is that if the volume tooltip is there when I right-click, it stays there (but is blank) until the mixer is closed.
Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Stupid - I forgot the & of course.The only problem is that if the volume tooltip is there when I right-click, it stays there (but is blank) until the mixer is closed.
bind .b <ButtonPress-3> { exec xtmix -geometry -0-23 &}
Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
If anyone else is interested, I have further modified my version, first so that it behaves the same as Rarsa's v 0.7 as far as I can tell (preserves balance until you turn the volume down to zero, icons change with level, if you click mute and then scroll the volume up, it starts at zero instead of the previous volume).
It has mute bound to mouse button 2 and launches the mixer with button 3.
Then I added a decent mute/unmount function, that preserves gain and balance.
Then I made it update the icon when you mouseover it (I don't think Rarsa had it doing this, but I could be wrong).
Then I put in a nasty hack to increase/decrease the volume by a different step size if you scroll with the control key held down.
I left in the code for the right click menu, so if it is really necessary you just need to comment one line and uncomment another.
N.B. That my balance control may work differently to Rarsa's.
The mute behaviour does have one slight querk, which is quite good depending on how you look at it. If you mute, then turn the volume up, then turn it back down to zero again, and then unmute it, instead of staying at zero or restoring to the default volumes, it restores to the volumes there were before you muted it. (The default volumes are just for unmuting if the volume is zero and it hasn't been muted since the program started).
--DISCLAIMER--
A lot of my code is substantially different to Rarsa's, so you shouldn't necessarily trust it. Most of it is quite new as well, so there might be bugs I haven't noticed.
As I mentioned, the reason I started with an older version is that 0.7 did not work in my ancient Puppy.
I haven't checked all the command line switches, so some of them could be broken.
It has mute bound to mouse button 2 and launches the mixer with button 3.
Then I added a decent mute/unmount function, that preserves gain and balance.
Then I made it update the icon when you mouseover it (I don't think Rarsa had it doing this, but I could be wrong).
Then I put in a nasty hack to increase/decrease the volume by a different step size if you scroll with the control key held down.
I left in the code for the right click menu, so if it is really necessary you just need to comment one line and uncomment another.
N.B. That my balance control may work differently to Rarsa's.
The mute behaviour does have one slight querk, which is quite good depending on how you look at it. If you mute, then turn the volume up, then turn it back down to zero again, and then unmute it, instead of staying at zero or restoring to the default volumes, it restores to the volumes there were before you muted it. (The default volumes are just for unmuting if the volume is zero and it hasn't been muted since the program started).
--DISCLAIMER--
A lot of my code is substantially different to Rarsa's, so you shouldn't necessarily trust it. Most of it is quite new as well, so there might be bugs I haven't noticed.
As I mentioned, the reason I started with an older version is that 0.7 did not work in my ancient Puppy.
I haven't checked all the command line switches, so some of them could be broken.
Code: Select all
#!/bin/sh
# =====
# USAGE
# =====
# This application can receive the following optional parameters:
# -orientation [horizontal | vertical]
# Specifies the orientation for the volume slider
# the default is vertical. Values can be shorthanded
# -mixer <mixer application>
# Specifies an more featured volume mixer to be
# invoked from the menu.
# -bg <colour>
# Specifies the background colour for the button
# -channel <number>
# Specifies the mixer channel to control the volume of
# Usually 0 is the master volume.
# -1step <number>
# The percentage increment/decrement when rolling the mouse wheel
# -2step <number>
# Increment/decrement rolling the wheel when holding the Control key.
#
# You can use shorthand for the parameters -o -m
# e.g.
# mini-volume -o hor -m /usr/sbin/pvolume-mixer.tcl
#
# =======
# LICENSE
# =======
# This program can be used and modified freely and you are welcome to
# redistribute it under the following terms:
#
# - This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# - Any derived works should be also distributed freely under an all-permisive
# license. Share the spirit of open source.
# - The following is not a requirement but a request:
# If you make changes to the application to fit a particular purpose or
# feature please share them with me contacting me at (rarsa at yahoo.com)
# This is an old version hacked a lot by Disciple to make features from
# version 0.7 compatible with extremely old Puppies (older tcl I think).
# 3 April 2008
#=============================================
# the next line restarts using wish \
exec wish "$0" "$@"
package require Img
set orient "vert"
set imgVolHigh "/usr/share/mini-icons/audio-volume-high.png"
set imgVolLow "/usr/share/mini-icons/audio-volume-low.png"
set imgVolMedium "/usr/share/mini-icons/audio-volume-medium.png"
set imgVolMute "/usr/share/mini-icons/audio-volume-muted.png"
set showing "false"
set bgcolor "gray"
set mixer {xtmix -geometry -0-23}
set channel 0
set savedvolumes {50 50}
set smallstep 2
set largestep 10
set volcommandleft [ subst { setvol $channel | cut -d" " -f1 } ]
set volcommandright [ subst { setvol $channel | cut -d" " -f2 } ]
#=============================================
proc getlevels { } {
global volcommandleft
global volcommandright
global volumeright
global volumeleft
set volumeleft [exec sh -c ($volcommandleft)]
set volumeright [exec sh -c ($volcommandright)]
if { $volumeleft != "0"} { set volumeleft [string trimleft $volumeleft "0"] } else { set volumeleft 0 }
if { $volumeright != "0"} { set volumeright [string trimleft $volumeright "0"] } else { set volumeright 0 }
}
#=============================================
proc getvolume { } {
global volcommandleft
global volcommandright
global volumeright
global volumeleft
getlevels
if { $volumeright>$volumeleft } {
set gain $volumeright
} else {
set gain $volumeleft
}
}
#=============================================
proc setvolume { level } {
global volcommandleft
global volcommandright
global volumeright
global volumeleft
global channel
getlevels
if { $volumeright != $volumeleft } {
if { $volumeright>$volumeleft } {
set leftlevel [expr {$level*$volumeleft/$volumeright}]
exec setvol $channel $leftlevel $level
} else {
set rightlevel [expr {$level*$volumeright/$volumeleft}]
exec setvol $channel $level $rightlevel
}
} else {
exec setvol $channel $level
}
setImage $level
}
#==============================================
proc parseParams { params } {
global orient
global bgcolor
global mixer
global channel
global smallstep
global largestep
for {set i 0} {$i < [llength $params]} {incr i} {
set arg [lindex $params $i]
if {[string first "-o" $arg] == 0} {
incr i;
if {[string first "h" [lindex $params $i]] == 0} {
set orient "hor"
}
}
if {[string first "-m" $arg] == 0} {
incr i;
catch {set mixer [ exec which [lindex $params $i] ] }
}
if {[string first "-bg" $arg] == 0} {
incr i;
set bgcolor [lindex $params $i]
}
if {[string first "-c" $arg] == 0} {
incr i;
set channel [lindex $params $i]
}
if {[string first "-1" $arg] == 0} {
incr i;
set smallstep [lindex $params $i]
}
if {[string first "-2" $arg] == 0} {
incr i;
set largestep [lindex $params $i]
}
}
}
#=============================================
proc tooltip:show {w arg} {
global prev
if {[eval winfo containing [winfo pointerxy .]]!=$w} {return}
if {[expr abs($prev - [clock clicks -milliseconds])] < 200 } {
set prev [clock clicks -milliseconds]
return
}
set prev [clock clicks -milliseconds]
set top $w.tooltip
catch {destroy $top}
toplevel $top -bd 1 -bg black
wm overrideredirect $top 1
pack [message $top.txt -aspect 10000 -bg lightyellow \
-font fixed -text [concat $arg [ getvolume ]]]
set wmx [winfo rootx $w]
if {[winfo rooty $w] < [winfo height $w]} {
set wmy [expr [winfo rooty $w]+[winfo height $w]]
} else {
set wmy [expr [winfo rooty $w]-[winfo height $w]]
}
set tmp1 [ winfo rooty $w ]
puts "wmx=$wmx wmy=$wmy rooty=$tmp1"
wm geometry $top \
[winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy
raise $top
}
#=============================================
proc volume:show {w} {
global gain
global orient
global showing
global bgcolor
set top $w.volume
catch {destroy $top}
if { $showing == "true" } {
set showing "false"
} else {
toplevel $top -bd 0 -bg black
wm overrideredirect $top 1
set gain [ getvolume ]
set wmx [winfo rootx $w]
if {$orient == "vert"} {
pack [scale $top.sv -show no -orient ver -from 100 -to 0 \
-sliderlength 20 -command { setvolume } \
-len 100 -bg $bgcolor -var gain]
if {[winfo rooty $w] > 75} {
set wmy [expr [winfo rooty $w]-110]
} else {
set wmy [expr [winfo rooty $w]+[winfo height $w]]
}
} else {
pack [scale $top.sv -show no -orient hor \
-sliderlength 5 -command { setvolume } \
-len 100 -bg $bgcolor -var gain]
set wmy [expr [winfo rooty $w]-[winfo height $w]]
}
bind $top.sv <ButtonRelease> [list tooltip:show %W Volume]
bind $top.sv <Button-4> {
set step $smallstep
volume:up %W
}
bind $top.sv <Button-5> {
set step $smallstep
volume:down %W
}
bind $top.sv <Control-Button-4> {
set step $largestep
volume:up %W
}
bind $top.sv <Control-Button-5> {
set step $largestep
volume:down %W
}
wm geometry $top \
[winfo reqwidth $top.sv]x[winfo reqheight $top.sv]+$wmx+$wmy
bind $w.volume <Any-Leave> {after 500 destroy %W
set showing "false"}
raise $top
set showing "true"
}
}
#=============================================
proc volume:up { w } {
global gain
global step
if { $gain > [expr 100 - $step] } {
set gain 100
} else {
set gain [expr $gain + $step]
}
setvolume $gain
after 200 [list tooltip:show $w Volume]
}
#=============================================
proc volume:down { w } {
global gain
global step
if { $gain < $step } {
set gain 0
} else {
set gain [expr $gain - $step]
}
setvolume $gain
after 200 [list tooltip:show $w Volume]
}
#=============================================
proc mute { } {
global defaultvolumes
global savedvolumes
global channel
global gain
set volumes [exec setvol $channel]
if { $volumes != "00 00" } {
set savedvolumes "$volumes"
exec setvol $channel 0
} else {
if { $savedvolumes != "00 00" } {
set command "setvol $channel $savedvolumes"
} else {
set command "setvol $channel $defaultvolumes"
}
exec sh -c ($command)
set savedvolumes $volumes
}
set gain [ getvolume ]
setImage $gain
destroy .b.tooltip
list tooltip:show $gain Volume
}
#=============================================
proc menu:show { w } {
.popupmenu post [winfo rootx $w] [winfo rooty $w]
}
#=============================================
proc setImage { level } {
global imgVolHigh
global imgVolLow
global imgVolMedium
global imgVolMute
img-mini-vol blank
if { $level == 0 } {
img-mini-vol configure -file $imgVolMute
} elseif { $level > 0 && $level <= 33 } {
img-mini-vol configure -file $imgVolLow
} elseif { $level > 33 && $level <= 66 } {
img-mini-vol configure -file $imgVolMedium
} else {
img-mini-vol configure -file $imgVolHigh
}
}
#=============================================
parseParams $argv
set gain [ getvolume ]
set prev [clock clicks -milliseconds]
image create photo img-mini-vol -format png
setImage $gain
button .b -text V -image img-mini-vol -bd 0 -bg $bgcolor
bind .b <ButtonPress-1> { list volume:show %W }
bind .b <Any-Enter> {
set gain [ getvolume ]
setImage $gain
after 500 [list tooltip:show %W Volume]
}
bind .b <Any-Leave> { destroy .b.tooltip }
bind .b <ButtonPress-1> { volume:show %W }
#bind .b <ButtonPress-2> { setvolume 0 }
#bind .b <ButtonPress-3> { menu:show %W }
bind .b <ButtonPress-2> { mute }
bind .b <ButtonPress-3> { exec sh -c ($mixer) & }
bind .b <Button-4> {
set step $smallstep
volume:up %W
}
bind .b <Button-5> {
set step $smallstep
volume:down %W
}
bind .b <Control-Button-4> {
set step $largestep
volume:up %W
}
bind .b <Control-Button-5> {
set step $largestep
volume:down %W
}
pack .b
menu .popupmenu -type normal -tearoff no
.popupmenu add command -command { exec mixer & } -label mixer
.popupmenu add command -command { mute } -label mute
bind .popupmenu <Any-Leave> { .popupmenu unpost }
Last edited by disciple on Wed 16 Apr 2008, 22:24, edited 2 times in total.
Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
I just added a line to the end of the mute function, to update the tooltip when you mute/unmute.
Note that if Rarsa's balance code is superior, it will only take a couple of minutes to splice my mute/unmute function into the 0.7 code.
Note that if Rarsa's balance code is superior, it will only take a couple of minutes to splice my mute/unmute function into the 0.7 code.
Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
hi rarsa,
i've a little problem with the mini-volume.tcl.
i'm running a pupplet based on fatfreepuppy 3.01.
my problem is, that the mini-volume.tcl has effect on the 'master' of Puppy Volume Mixer but the volume on my system is changed by the pcm.
is that an issue of settings or my setup or may i change something in mini-volume.tcl?
thanks in advance
aragon
i've a little problem with the mini-volume.tcl.
i'm running a pupplet based on fatfreepuppy 3.01.
my problem is, that the mini-volume.tcl has effect on the 'master' of Puppy Volume Mixer but the volume on my system is changed by the pcm.
is that an issue of settings or my setup or may i change something in mini-volume.tcl?
thanks in advance
aragon
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Surely the master control also changes the volume?
Anyway, if you want mini-volume.tcl to change something other than the master volume.
1. Open a terminal, type, and press enter. This will tell you which channel (or whatever it is called) is which. will tell you the levels on channel 1.
will change both the left and right levels on channel 1 to 60% of the maximum.
will change the left and right levels on channel 3 to 49% and 63% respectively.
You should be able to confirm the correct channel, then open mini-volume.tcl in a text editor, and change all the setvol commands to use it - just change the first number after every setvol to the right one (it will be zero at the moment).
Otherwise, you can replace rarsa's mini-volume.tcl with the one I just posted, because I added an argument to specify the mixer channel when you start mini-volume.tcl. So you would just have to replace the mini-volume.tcl script, and edit the jwm config file (or anything else that starts mini-volume.tcl) to add a parameter like on the end of the command.
Anyway, if you want mini-volume.tcl to change something other than the master volume.
1. Open a terminal, type
Code: Select all
setvol
Code: Select all
setvol 1
Code: Select all
setvol 1 60
Code: Select all
setvol 3 49 63
You should be able to confirm the correct channel, then open mini-volume.tcl in a text editor, and change all the setvol commands to use it - just change the first number after every setvol to the right one (it will be zero at the moment).
Otherwise, you can replace rarsa's mini-volume.tcl with the one I just posted, because I added an argument to specify the mixer channel when you start mini-volume.tcl. So you would just have to replace the mini-volume.tcl script, and edit the jwm config file (or anything else that starts mini-volume.tcl) to add a parameter like
Code: Select all
-c 5
Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
hi discible,
thanks for the answer.
no, master-volume does not effect anything at the moment, only pcm-volume.
it's a little mystery to me. in my last pupplet build on fatfree 3.01 with fluxbox i didn't use the mini-volume.tcl. but in that setup the master-volume and the pcm-volume in puppy-mixer do "work" with the same machines.
i am now building a pupplet also based on fatfree 3.01 with jwm in an poormans-xfce-flavour to reduce the work for a new propper setup with new versions of puppy. in that setup i've noticed the problem. this might be a problem with the alsa-setup but as the pcm-volume does work on all my current and previous setups, i wanted to change it to this on.
to cut a long story short: i will check out your version later and report of my success.
cheers
aragon
thanks for the answer.
no, master-volume does not effect anything at the moment, only pcm-volume.
it's a little mystery to me. in my last pupplet build on fatfree 3.01 with fluxbox i didn't use the mini-volume.tcl. but in that setup the master-volume and the pcm-volume in puppy-mixer do "work" with the same machines.
i am now building a pupplet also based on fatfree 3.01 with jwm in an poormans-xfce-flavour to reduce the work for a new propper setup with new versions of puppy. in that setup i've noticed the problem. this might be a problem with the alsa-setup but as the pcm-volume does work on all my current and previous setups, i wanted to change it to this on.
to cut a long story short: i will check out your version later and report of my success.
cheers
aragon
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
hi disciple,
short report:
I've only had to change line 60 of the new script from
set channel 0 to
set channel 4
and now it work.
thanks for your help.
aragon
short report:
I've only had to change line 60 of the new script from
set channel 0 to
set channel 4
and now it work.
thanks for your help.
aragon
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html