Posted: Mon 26 Feb 2007, 09:22
Thanks for enlarging the volume slider, I like the new applet better than any previous.
Nathan
Nathan
READ-ONLY Archive
https://oldforum.puppylinux.com/
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.There is a tcl/tk extension to handle system trays.
You need to install the latest version of the Volume mixer and the latest version of the mini-volume.Kal wrote:Respect balance doesn't seem to be working properly.
Thank you for reporting it. I new about the problem but I thought the fix was in 0.6.Kal wrote:Thanks again, Kal
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.
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 }
Code: Select all
setvol
Code: Select all
setvol 1
Code: Select all
setvol 1 60
Code: Select all
setvol 3 49 63
Code: Select all
-c 5