Originally posted by pemartins
View Post
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
-
"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.
- Top
- Bottom
-
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 PostIn 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?
- Top
- Bottom
Comment
-
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.
- Top
- Bottom
Comment
-
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)
Last edited by pemartins; Jun 15, 2018, 01:16 PM.
- Top
- Bottom
Comment
Comment