Tray Volume selector - Updated Mar 2007!

Stuff that has yet to be sorted into a category.
Message
Author
User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#16 Post by Lobster »

8) 0.4 is very polished. Look forward to seeing it in Puppy Barbie 2.14
http://puppylinux.org/wikka/Puppy214

:)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
WhoDo
Posts: 4428
Joined: Wed 12 Jul 2006, 01:58
Location: Lake Macquarie NSW Australia

#17 Post by WhoDo »

Love the applet, rarsa! Any chance us addicted Icewm'ers can get a compatible version?

MU managed to get Blinky working for me, so it should be possible but only you can say for sure!

Cheers

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#18 Post by Pizzasgood »

C programs can use eggtray to show up in IceWM. That's how Blinky does it. If I remember right though, this volume app is a TCL program. I don't know if those can do that.

It would be nice though.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

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

#19 Post by rarsa »

There is a tcl/tk extension to handle system trays. But I would need to install it and make it work. I may get around to it at some point.
[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:

#20 Post by rarsa »

Version 0.6

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-02-26 - 01:00 (version 0.6)
- Added a parameter to select a mixer application to launch on right click
- Added right click menu to select either "mute" or "mixer"
- Added code to respect balance selected in another mixer
- Enlarged the slider handle
- Cleaned up the code a little.
[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
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

Post Reply