Announcement

Collapse
No announcement yet.

Use the screen corners to change the sound volume using the mouse wheel?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by pemartins View Post
    In full screen mode there's no way of using the volume icon on a panel, that's the main reason I'm looking for this. And just moving the mouse to one side and using the wheel is also way faster, you can do it without even looking at the screen (very useful for a wireless mouse).
    Do you have function keys? On my Acer V3-771G is a key with a blue "Fn" on it. When I hold it down and press the up or down arrows I can raise or lower the sound on an app that takes up the full screen and hides the panel. In System Settings --> Short Cuts --> Global Short Cuts is a panel containing "Audio Volume". Select it and the right panel shows "volume up" and "volume down" settings where you can assign keys.
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    Comment


      #17
      Thank y'all very much once again.

      A shortcut using a key plus the mouse wheel I have already set, I set Super (Windows key) plus mouse wheel for it. The goal is not having to use the keyboard at all.

      But guys I already have the script and it's working perfectly as I mentioned and pasted it in the previous page:
      https://www.kubuntuforums.net/showth...l=1#post416295
      about it I just had these two questions:
      Originally posted by pemartins View Post
      In this script is there ways of:
      1) make it work not just on the top and button edges but all along the sides from top to bottom?
      2) I noticed that, when the script is running, python uses from 1 to 4% of the cpu. Is there a way to lower this cpu usage?

      Comment


        #18
        I'll mark this one as solved since I already reached its goal, nevertheless if someone could help on changing the code so the volume change would also work on the left and right edges of the screen (and not only in top and bottom left/right corners) it would be very helpful indeed.

        Thank you all for your help.

        Comment


          #19
          Ok here's a script so you can set the entire left edge of the screen to use the mouse wheel to control the sound volume, as well as the top and bottom right corners:

          Code:
          #!/usr/bin/env python
          #-*-coding:utf-8-*-
          # mehmet nural altintas <mehmet.nrl@hotmail.com>
          # This script is edited version of  "record_demo.py -- demonstrate record extension" that can be found here: http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/trunk/examples/
          # python-xlib package must be installed to run this script
          # sudo apt-get install python-xlib
          
          import os
          from Xlib import X, display
          from Xlib.ext import record
          from Xlib.protocol import rq
          
          Screen_resolution = (1366,768) # write here your screen resolution
          
          Corner_area = 20 # write here the size of the virtual squares that receive wheel up and down event at the corner of your screen 
          
          # Let's set up the commands
          def volume_up():
          
            os.system("amixer -D pulse -q sset Master 7%+ unmute & pid=$!")
            # write your bash command between "" to volume up
          
            # use "& pid=$!" end of your command to prevent freezing python script if your command takes long time to process.
          
          def volume_down():
          
            os.system("amixer -D pulse -q sset Master 7%- unmute & pid=$!")
            # write your bash command between "" to volume down
          
          record_dpy = display.Display()
          
          ctx = record_dpy.record_create_context(
                0,
                [record.AllClients],
                [{
                        'core_requests': (0, 0),
                        'core_replies': (0, 0),
                        'ext_requests': (0, 0, 0, 0),
                        'ext_replies': (0, 0, 0, 0),
                        'delivered_events': (0, 0),
                        'device_events': (X.KeyPress, X.MotionNotify),
                        'errors': (0, 0),
                        'client_started': False,
                        'client_died': False,
                }])
          
          def record_callback(reply):
          
            data = reply.data
            while len(data):
                event, data = rq.EventField(None).parse_binary_value(data, record_dpy.display, None, None)
                
                if event.type == X.ButtonPress:
                    print  event.detail, event.root_x, event.root_y
          
                    #let's create left side
                    if ( event.root_x < Corner_area ):
          
                       print "left side detected" 
                       # event.detail 4 means wheel up event
          
                       if event.detail is 4 : 
          
                          print "volume up!"
          
                          volume_up() 
          
                       if event.detail is 5 :
          
                          print "volume down!"
          
                          volume_down() 
                          
                          
                    # Let's set up right up corner 
          
                    if all( [event.root_x > Screen_resolution[0] - Corner_area, event.root_y < Corner_area] ):
          
                       print "right up corner detected" 
          
                       # event.detail 4 means wheel up event
          
                       if event.detail is 4 : 
                          print "volume up!"
                          volume_up() 
          
                       # event.detail 5 means wheel down event
          
                       if event.detail is 5 :
                          print "volume down!"
                          volume_down() 
          
                    # Let's set up right down corner
          
                    if all( [event.root_x > Screen_resolution[0] - Corner_area, event.root_y > Screen_resolution[1] - Corner_area] ):
          
                       print "right down corner detected"
          
                       if event.detail is 4 :
                          print "volume up!"
                          volume_up() 
          
                       if event.detail is 5 :
                          print "volume down!"
                          volume_down() 
          
                    
                elif event.type == X.ButtonRelease:
          
                    print  event.detail, event.root_x, event.root_y
                    
                elif event.type == X.MotionNotify:
          
                    print event.root_x, event.root_y
                    
          
          record_dpy.record_enable_context(ctx, record_callback)
          Source: https://github.com/mnural/xlib-pyvolume/issues/1
          Last edited by pemartins; Jun 15, 2018, 01:16 PM.

          Comment

          Working...
          X