Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 07:50
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Tray Volume selector - Updated Mar 2007!
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 3 [42 Posts]   Goto page: Previous 1, 2, 3
Author Message
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Wed 12 Mar 2008, 00:18    Post subject:  

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.
Back to top
View user's profile Send private message 
HairyWill


Joined: 26 May 2006
Posts: 2949
Location: Southampton, UK

PostPosted: Wed 12 Mar 2008, 03:26    Post subject:  

I think it is relevant.
This volume app is still the better candidate for the developing 3 series.

_________________
Will
contribute: community website, screenshots, puplets, wiki, rss
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Mon 31 Mar 2008, 19:57    Post subject:  

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.

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Tue 01 Apr 2008, 19:53    Post subject:  

Quote:
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 &}

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Fri 04 Apr 2008, 23:12    Post subject:
Subject description: Now with unmute and 2 scroll step sizes...
 

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:
#!/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 }

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!

Last edited by disciple on Wed 16 Apr 2008, 18:24; edited 2 times in total
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Wed 09 Apr 2008, 20:01    Post subject:  

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.

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Thu 10 Apr 2008, 10:53    Post subject:  

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

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Thu 10 Apr 2008, 21:24    Post subject:  

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:
setvol
, and press enter. This will tell you which channel (or whatever it is called) is which.
Code:
setvol 1
will tell you the levels on channel 1.
Code:
setvol 1 60
will change both the left and right levels on channel 1 to 60% of the maximum.
Code:
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:
-c 5
on the end of the command.
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Fri 11 Apr 2008, 03:35    Post subject:  

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

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Back to top
View user's profile Send private message 
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Fri 11 Apr 2008, 10:59    Post subject:  

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

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Fri 11 Apr 2008, 19:54    Post subject:  

Yeah, I realized last night you could just do that Smile
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Wed 16 Apr 2008, 18:25    Post subject:  

Oops - don't know why I thought that line made the tooltip in the mute function work.
I've added another line now and it does Smile

Oops - that actually still doesn't work if it is in the JWM tray (but it does if it isn't). I give up Sad

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 3 [42 Posts]   Goto page: Previous 1, 2, 3
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1523s ][ Queries: 13 (0.0299s) ][ GZIP on ]