debianmacno-cups
Last change
on this file since 3ee56cf was
3ee56cf,
checked in by Mats Ahlgren <mats@…>, 14 years ago
|
added remctl helper file called volume-helper.py
this script smoothly moves volume up/down over 3sec (large step)
made volume-up and volume-down call it (volume-helper.py +/-)
this commit also contains a bugfix by quentin: previously
"amixer set PCM -3dB" would recognize -3dB as "option 3dB",
fixed by means of using "--" in the calling convention
|
-
Property mode set to
100755
|
File size:
1.0 KB
|
Line | |
---|
1 | #!/usr/bin/python |
---|
2 | |
---|
3 | from __future__ import division |
---|
4 | from subprocess import * |
---|
5 | import sys |
---|
6 | import math |
---|
7 | import time |
---|
8 | import os |
---|
9 | j = os.path.join |
---|
10 | |
---|
11 | arg = sys.argv[1] |
---|
12 | currentDir = os.path.split(__file__)[0] |
---|
13 | #sys.path[:0] = [currentDir] |
---|
14 | |
---|
15 | def getVolume(): |
---|
16 | """ |
---|
17 | Returns current PCM volume percentage as int |
---|
18 | """ |
---|
19 | v = int(Popen(j(currentDir,'volume-get'), stdout=PIPE).communicate()[0].split()[0]) |
---|
20 | return v |
---|
21 | |
---|
22 | def setVolume(percent): |
---|
23 | """ |
---|
24 | Over the course of 3 seconds, in steps of 0.3sec, linearly sets |
---|
25 | volume between [current vol]-->[new vol] |
---|
26 | """ |
---|
27 | v = getVolume() |
---|
28 | newV = percent |
---|
29 | for i in range(10): |
---|
30 | frac = i/10 |
---|
31 | tempV = int(v + (newV-v)*frac) |
---|
32 | command = ['amixer', 'set', 'PCM', str(tempV)] |
---|
33 | call(command, stdout=PIPE) |
---|
34 | time.sleep(0.3) |
---|
35 | |
---|
36 | v = getVolume() |
---|
37 | map = { |
---|
38 | '+': int(math.ceil( v*1.2 + .001 )), |
---|
39 | '-': int(math.floor( v/1.2 + .001 )) |
---|
40 | } |
---|
41 | |
---|
42 | newVolume = map[arg] |
---|
43 | print 'Smoothly modifying over 3 seconds...' |
---|
44 | sys.stdout.flush() |
---|
45 | setVolume(newVolume) |
---|
46 | print 'Volume adjust finished.' |
---|
47 | call([j(currentDir,'volume-zephyr')]) |
---|
Note: See
TracBrowser
for help on using the repository browser.