Tray Volume selector - Updated Mar 2007!

Stuff that has yet to be sorted into a category.
Message
Author
User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#21 Post by Nathan F »

Thanks for enlarging the volume slider, I like the new applet better than any previous.

Nathan
Bring on the locusts ...

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#22 Post by Nathan F »

There is a tcl/tk extension to handle system trays.
Are you speaking of tktray I imagine? I took a peek at it and can't compile the source. A very cursory peek I should add. Anyway I would give a hearty thanks to be able to use this in something other than jwm.

Nathan
Bring on the locusts ...

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#23 Post by Nathan F »

OK, never mind that. It turns out some headers were missing which are actually part of the source distribution for tk. Grab it, put them in place, and tktray compiles fine.

Nathan
Bring on the locusts ...

Kal
Posts: 626
Joined: Thu 05 May 2005, 16:59
Location: California, High Desert

#24 Post by Kal »

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

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#25 Post by rarsa »

Kal wrote:Respect balance doesn't seem to be working properly.
You need to install the latest version of the Volume mixer and the latest version of the mini-volume.
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

Kal
Posts: 626
Joined: Thu 05 May 2005, 16:59
Location: California, High Desert

#26 Post by Kal »

If mini-volume-0.6.pet and pvolume-mixer-0.2.pet are not the newest, where are they obtained? I must have missed it some where.
Good Luck, Kal

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#27 Post by rarsa »

Those are the latest ones. I will investigate.
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#28 Post by rarsa »

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
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

Kal
Posts: 626
Joined: Thu 05 May 2005, 16:59
Location: California, High Desert

New Upgrades - OK

#29 Post by Kal »

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

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

Re: New Upgrades - OK

#30 Post by rarsa »

Kal wrote:Thanks again, Kal
Thank you for reporting it. I new about the problem but I thought the fix was in 0.6.
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#31 Post by disciple »

I know this is less relevant now because of Dingo, but just thought I'd mention a small change that I make to this as I find it useful - making it mute when clicked with the middle mouse button.

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#32 Post by HairyWill »

I think it is relevant.
This volume app is still the better candidate for the developing 3 series.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#33 Post by disciple »

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.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#34 Post by disciple »

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.
Stupid - I forgot the & of course.
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

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#35 Post by disciple »

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.

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

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#36 Post by disciple »

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.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#37 Post by aragon »

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

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#38 Post by disciple »

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

Code: Select all

setvol
, and press enter. This will tell you which channel (or whatever it is called) is which.

Code: Select all

setvol 1
will tell you the levels on channel 1.

Code: Select all

setvol 1 60
will change both the left and right levels on channel 1 to 60% of the maximum.

Code: Select all

setvol 3 49 63
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

Code: Select all

-c 5 
on the end of the command.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#39 Post by aragon »

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

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#40 Post by aragon »

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

Post Reply