1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/bin/python3
-
- import subprocess as sp
- import sys
- g_step = 10
-
-
- def set_volume(value):
- sp.check_output(["xbacklight", "-set", str(int(value))])
-
-
- def get_volume():
- return round(float(sp.check_output(["xbacklight",
- "-get"]).decode().split()[0]))
-
-
- def volume_down():
- vol = get_volume()
- if vol <= g_step + 1:
- set_volume(1)
- else:
- set_volume(vol - g_step)
-
-
- def volume_up():
- vol = get_volume()
- print(vol)
- if vol <= 1:
- set_volume(g_step)
- else:
- set_volume(vol + g_step)
-
-
- def main():
- if len(sys.argv) != 2:
- return
- if sys.argv[1] == "up":
- volume_up()
- if sys.argv[1] == "down":
- volume_down()
-
-
- if __name__ == "__main__":
- main()
|