Add dot_config/qtile/.keep

Add dot_config/qtile/__pycache__/.keep
Add dot_config/qtile/__pycache__/bars.cpython-38.pyc
Add dot_config/qtile/__pycache__/bars.cpython-39.pyc
Add dot_config/qtile/__pycache__/colors.cpython-38.pyc
Add dot_config/qtile/__pycache__/colors.cpython-39.pyc
Add dot_config/qtile/__pycache__/config-done.cpython-38.pyc
Add dot_config/qtile/__pycache__/config.cpython-38.pyc
Add dot_config/qtile/__pycache__/config.cpython-39.pyc
Add dot_config/qtile/__pycache__/groups.cpython-38.pyc
Add dot_config/qtile/__pycache__/groups.cpython-39.pyc
Add dot_config/qtile/__pycache__/keys.cpython-38.pyc
Add dot_config/qtile/__pycache__/keys.cpython-39.pyc
Add dot_config/qtile/__pycache__/layouts.cpython-38.pyc
Add dot_config/qtile/__pycache__/layouts.cpython-39.pyc
Add dot_config/qtile/__pycache__/screens.cpython-38.pyc
Add dot_config/qtile/__pycache__/screens.cpython-39.pyc
Add dot_config/qtile/bars.py
Add dot_config/qtile/colors.py
Add dot_config/qtile/config.py
Add dot_config/qtile/groups.py
Add dot_config/qtile/keys.py
Add dot_config/qtile/layouts.py
Add dot_config/qtile/old_configs/.keep
Add dot_config/qtile/old_configs/config.py
Add dot_config/qtile/old_configs/sweenu/.keep
Add dot_config/qtile/old_configs/sweenu/bars.py
Add dot_config/qtile/old_configs/sweenu/colors.py
Add dot_config/qtile/old_configs/sweenu/config.py
Add dot_config/qtile/old_configs/sweenu/keys.py
Add dot_config/qtile/old_configs/sweenu/util/.keep
Add dot_config/qtile/old_configs/sweenu/util/__main__.py
Add dot_config/qtile/old_configs/sweenu/util/backlight.py
Add dot_config/qtile/old_configs/sweenu/util/monitor.py
Add dot_config/qtile/old_configs/sweenu/util/screenshot.py
Add dot_config/qtile/old_configs/sweenu/util/soundcard.py
Add dot_config/qtile/old_configs/sweenu/widgets.py
Add dot_config/qtile/screens.py
Add dot_config/qtile/scripts/.keep
Add dot_config/qtile/scripts/executable_autostart.sh
Add dot_config/qtile/themes/.keep
Add dot_config/qtile/themes/ayu-dark.json
Add dot_config/qtile/themes/dracula.json
Add dot_config/qtile/themes/hopscotch.json
Add dot_config/qtile/themes/material-darker.json
Add dot_config/qtile/themes/nord.json
Add dot_config/qtile/themes/one-dark.json
Add dot_config/qtile/themes/operator.json
Add dot_config/qtile/themes/royal.json
Add dot_config/qtile/themes/seashells.json
Add dot_config/qtile/themes/smyck.json
Add dot_config/qtile/themes/spacedust.json
Add dot_config/qtile/themes/spacegray.json
Add dot_config/qtile/themes/square.json
Add dot_config/qtile/themes/tomorrow-nb.json
This commit is contained in:
eeleater 2021-08-26 20:17:03 +02:00
parent d84f84d6cd
commit bc838a571d
55 changed files with 1181 additions and 0 deletions

View file

@ -0,0 +1,50 @@
from subprocess import run, PIPE
from typing import Optional
from pynput import mouse
from . import qtile_func
class Backlight:
def __init__(self, ctrl: Optional[str]=None) -> None:
self.command = ['xbacklight']
if ctrl:
self.command += ['-ctrl', ctrl]
def _get_brightness(self) -> int:
return int(run(self.command + ['-get'], stdout=PIPE).stdout)
def _set_brightness(self, percentage: int) -> None:
run(self.command + [f'-set', str(percentage)])
@qtile_func
def change_backlight(self, action: str) -> None:
"""
Increase or decrease bightness.
Takes 'dec' or 'inc' as parameter. Goes 1% percent at a time from
1% to 40% and 10% at a time from 40% to 100%.
"""
brightness = self._get_brightness()
if brightness != 1 or action != 'dec':
if (brightness > 49 and action == 'dec') \
or (brightness > 39 and action == 'inc'):
run(self.command + [f'-{action}', '10', '-fps', '10'])
else:
run(self.command + [f'-{action}', '1'])
@qtile_func
def turn_off_screen(self, screen_offset: int) -> None:
"""
Turn off the laptop's screen.
Use xset if there is only one screen, else, set backlight to
zero. In both case, moving the mouse will turn on the screen.
"""
current_brightness = self._get_brightness()
self._set_brightness(0)
def on_move(x: int, y: int):
if x > screen_offset:
self._set_brightness(current_brightness)
raise mouse.Listener.StopException
mouse.Listener(on_move=on_move).start()