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

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

    Is there a way I can use the screen corners to change the sound volume using the mouse wheel?

    Using Compiz in MATE I was used to having left, right and bottom corners of the screen set to change volume, something like assigning these commands to the buttons when the mouse pointer is at a corner:
    pactl set-sink-volume 1 +10% for button 6
    pactl set-sink-volume 1 -10% for button 5

    Is there a way I can do this in Kubuntu 18.04 (KDE using KWin)?

    edit
    Solution scripts:
    https://www.kubuntuforums.net/showth...l=1#post416295
    and
    https://www.kubuntuforums.net/showth...l=1#post416652
    Last edited by pemartins; Jun 15, 2018, 01:15 PM.

    #2
    In System Settings --> Desktop Behavior --> ScreenEdges are six buttons. You can right click on a button and select "Run a command". How you set which command to run is not apparent and I do not know, but maybe Kubical or someone else does.
    "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


      #3
      Originally posted by GreyGeek View Post
      In System Settings --> Desktop Behavior --> ScreenEdges are six buttons. You can right click on a button and select "Run a command". How you set which command to run is not apparent and I do not know, but maybe Kubical or someone else does.
      it opens krunner like in "alt +F2"

      VINNY
      i7 4core HT 8MB L3 2.9GHz
      16GB RAM
      Nvidia GTX 860M 4GB RAM 1152 cuda cores

      Comment


        #4
        Originally posted by vinnywright View Post
        it opens krunner like in "alt +F2"

        VINNY
        So, if "Application Launcher" is selected does click the corner still open Krunner? If so, there is not really anything that is different since either a command or the name of an app has to be manually entered each time. That's not helpful.
        "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


          #5
          Originally posted by GreyGeek View Post
          So, if "Application Launcher" is selected does click the corner still open Krunner? If so, there is not really anything that is different since either a command or the name of an app has to be manually entered each time. That's not helpful.
          yes it opens krunner when you click the corner , and no it's not helpful , the keybord shortcut is just as quick and if the desktop has focus you can just start typing and it opens .

          VINNY
          i7 4core HT 8MB L3 2.9GHz
          16GB RAM
          Nvidia GTX 860M 4GB RAM 1152 cuda cores

          Comment


            #6
            Interesting ... And a cool trick.

            Sometimes it's just easier to turn the volume knob - like the Bose Companion 2 speakers next to my monitor. Or left click the speaker icon in the tray and use the mouse wheel there.
            The next brick house on the left
            Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.27.11​| Kubuntu 24.04 | 6.8.0-31-generic



            Comment


              #7
              Thank y'all for your help!

              Help me out here because I think we're almost there, I found this to be quite useful: https://askubuntu.com/questions/6010.../601209#601209

              In example, when I use this command:
              Code:
              xdotool behave_screen_edge top-left exec pactl set-sink-volume 0 +10%
              the volume raises 10% as I move the mouse pointer to the top left corner. Now I'm only missing a script so that action is only performed when a mouse button is clicked, in this particular case when the mouse wheel is moved.
              I am not capable of making such a script myself.

              I already have these commands added to the file ~/.xbindkeysrc so I can use Super key plus mouse wheel to control the volume, they can perhaps be helpful (for some season I used amixer instead of pactl, basically they both do the same volume control action but pactl raises the volume above 100% which is sometimes useful):
              Code:
              "amixer -D pulse -q sset Master 7%+ unmute"
              m:0x50 + c:133 + b:4
              "amixer -D pulse -q sset Master 7%- unmute"
              m:0x50 + c:133 + b:5
              edit:
              Maybe it's useful, here's the output of xev for button 4 (mouse wheel up) and button 5 (mouse wheel down):
              Code:
              $ xev | grep -A 2 Button
              ButtonPress event, serial 40, synthetic NO, window 0x3c00001,
               root 0x4c7, subw 0x0, time 7996725, (84,52), root:(842,594),
               state 0x10, button 4, same_screen YES
              --
              ButtonRelease event, serial 40, synthetic NO, window 0x3c00001,
               root 0x4c7, subw 0x0, time 7996725, (84,52), root:(842,594),
               state 0x810, button 4, same_screen YES
              --
              ButtonPress event, serial 40, synthetic NO, window 0x3c00001,
               root 0x4c7, subw 0x0, time 8002228, (79,51), root:(837,593),
               state 0x10, button 5, same_screen YES
              --
              ButtonRelease event, serial 40, synthetic NO, window 0x3c00001,
               root 0x4c7, subw 0x0, time 8002228, (79,51), root:(837,593),
               state 0x1010, button 5, same_screen YES
              Last edited by pemartins; Jun 09, 2018, 10:07 AM. Reason: add xev info

              Comment


                #8
                Seems like someone had the same idea not long ago, here's a script that will allow using the mouse wheel to control the volume on the four edges of the screen:
                https://github.com/mnural/xlib-pyvolume

                Already changed it to work with my sound device and removed the constant printing on the screen of the mouse pointer location:
                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: [URL]http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/trunk/examples/[/URL]
                # 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 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 left up corner
                
                         if all( [event.root_x < Corner_area , event.root_y < Corner_area] ):
                
                            print "left up corner detected"
                
                            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 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() 
                
                         # Let's set up left down corner 
                
                         if all( [event.root_x < Corner_area , event.root_y > Screen_resolution[1] - Corner_area] ):
                
                            print "left 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)
                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


                  #9
                  How is that better than just hovering your mouse over the sound icon in the system tray and rolling your thumb wheel up or down?
                  "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


                    #10
                    Originally posted by GreyGeek View Post
                    How is that better than just hovering your mouse over the sound icon in the system tray and rolling your thumb wheel up or down?
                    If you don't use any panels, you can't do that

                    Which gives me an idea:
                    Create an autohide panel with only an audio volume widget, no systray or taskbar etc , shrunk down to only show the widget in the corner desired. Mouse over to that corner and it pops out, then mouse wheel to adjust volume.

                    Hacky, but genius I say!

                    Sent from my LG-H931 using Tapatalk

                    Comment


                      #11
                      That's a GREAT idea, Claydoh!
                      "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


                        #12
                        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).

                        Comment


                          #13
                          I imagine it is possible with kwin scripting, but you'd have to learn that, or find someone to do it.

                          Comment


                            #14
                            No-one has mentioned the dbus or qdbus yet, so I thought I might. There's qdbus commands to query or set the volume. But something taking button events from the windowing system in full screen mode is a part of the requirement... I've no idea.

                            Regards, John Little
                            Regards, John Little

                            Comment


                              #15
                              Well the Plasma/Kwin master sez it is possible, I think
                              https://forum.kde.org/viewtopic.php?f=67&t=128169
                              So you invoke qdbus or dbus commands via kwin scripting
                              https://techbase.kde.org/Development...ipting/API_4.9
                              All g(r)eek to me tho

                              Comment

                              Working...
                              X