dotfiles/dot_config/qtile/old_configs/sweenu/keys.py
eeleater bc838a571d 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
2021-08-26 20:17:03 +02:00

124 lines
4.9 KiB
Python

from libqtile.config import Key, Drag
from libqtile.command import lazy
from util.backlight import Backlight
from util.screenshot import screenshot
from util.soundcard import SoundCard
from util import qtile_func
# super = mod4, alt = mod1
mod = 'mod4'
BROWSER = '{{ browser }}'
TERM= '{{ term }}'
MUSIC_PLAYER = 'spotify'
# add 'PlayPause', 'Next' or 'Previous'
spotify_cmd = ('dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify '
'/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.')
amixer_cmd = 'amixer -D pulse set Master'
rofi_cmd = 'rofi -combi-modi window,run -show combi -modi combi -monitor -4'
sc = SoundCard('alsa_card.pci-0000_00_1f.3')
def app_or_group(group, app):
"""Go to app if already open else open it."""
def f(qtile):
if group in {'music'}:
qtile.cmd_to_screen(1)
try:
qtile.groupMap[group].cmd_toscreen()
except KeyError:
qtile.cmd_spawn(app)
return f
def go_to_group(group):
"""The groups 'asdf' are accessible on screen 1, 'uiop' on screen 2."""
def f(qtile):
if group in 'asdf':
qtile.cmd_to_screen(0)
qtile.groupMap[group].cmd_toscreen()
elif group in 'uiop':
qtile.cmd_to_screen(1)
qtile.groupMap[group].cmd_toscreen()
return f
# TODO: make this function work for more than two monitors
def get_backlight_keys(qtile):
monitors = qtile.conn.monitors
keys = []
for monitor in monitors:
bl = Backlight(ctrl=monitor.backlight_ctrl)
if monitor.name.startswith('eDP'):
keys.append(Key([], 'XF86MonBrightnessUp', lazy.function(bl.change_backlight('inc'))))
keys.append(Key([], 'XF86MonBrightnessDown', lazy.function(bl.change_backlight('dec'))))
keys.append(Key([], 'F7', lazy.function(bl.turn_off_screen(monitor.x))))
else:
keys.append(Key([mod], 'Up', lazy.function(bl.change_backlight('inc'))))
keys.append(Key([mod], 'Down', lazy.function(bl.change_backlight('dec'))))
keys.append(Key([mod], 'F7', lazy.function(bl.turn_off_screen(monitor.x))))
return keys
keys = [
Key([mod, 'control'], 'p', lazy.spawn('xbacklight -set 50')),
Key([mod], 'k', lazy.layout.down()), # noqa
Key([mod], 'j', lazy.layout.up()), # noqa
Key([mod], 'space', lazy.layout.next()), # noqa
Key([mod, 'control'], 'k', lazy.layout.shuffle_down()), # noqa
Key([mod, 'control'], 'j', lazy.layout.shuffle_up()), # noqa
Key([mod, 'shift'], 'h', lazy.layout.client_to_previous()), # noqa
Key([mod, 'shift'], 'l', lazy.layout.client_to_next()), # noqa
Key([mod, 'shift'], 'space', lazy.layout.rotate()), # noqa
Key([mod, 'shift'], 'Return', lazy.layout.toggle_split()), # noqa
Key([mod], 'slash', lazy.screen.toggle_group()), # noqa
Key([mod], 'x', lazy.window.kill()), # noqa
Key([mod], 'y', lazy.window.toggle_floating()), # noqa
Key([mod], '1', lazy.to_screen(0)), # noqa
Key([mod], '2', lazy.to_screen(1)), # noqa
Key([mod], 'Tab', lazy.next_layout()), # noqa
Key([mod, 'control'], 'r', lazy.restart()), # noqa
Key([mod, 'control'], 'q', lazy.shutdown()), # noqa
# Audio
Key([], 'XF86AudioMute', lazy.spawn(amixer_cmd + ' 1+ toggle')), # noqa
Key([], 'XF86AudioRaiseVolume', lazy.spawn(amixer_cmd + ' 5%+')), # noqa
Key([], 'XF86AudioLowerVolume', lazy.spawn(amixer_cmd + ' 5%-')), # noqa
Key([], 'XF86AudioPlay', lazy.spawn(spotify_cmd + 'PlayPause')), # noqa
Key([], 'XF86AudioNext', lazy.spawn(spotify_cmd + 'Next')), # noqa
Key([], 'XF86AudioPrev', lazy.spawn(spotify_cmd + 'Previous')), # noqa
Key([mod], 'bracketleft', lazy.function(sc.change_sink('prev'))), # noqa
Key([mod], 'bracketright', lazy.function(sc.change_sink('next'))), # noqa
Key([], 'F8', lazy.function(sc.swap_profile())), # noqa
# Apps
Key([mod], 't', lazy.spawn(rofi_cmd)), # noqa
Key([mod], 'Return', lazy.spawn(TERM)), # noqa
Key([mod], 'b', lazy.spawn(BROWSER)), # noqa
Key([mod], 'g', lazy.function(app_or_group('game', 'steam'))), # noqa
Key([mod], 'n', lazy.function(app_or_group('chat', 'discord'))), # noqa
Key([mod], 'm', lazy.function(app_or_group('music', MUSIC_PLAYER))), # noqa
# Screenshots
Key([], 'Print', lazy.function(screenshot())), # noqa
Key(['control'], 'Print', lazy.spawn('deepin-screenshot')), # noqa
]
for i in 'asdfuiop':
keys.append(Key([mod], i, lazy.function(go_to_group(i)))) # noqa
keys.append(Key([mod, 'shift'], i, lazy.window.togroup(i))) # noqa
mouse = [
Drag([mod], "Button1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
Drag([mod, 'control'], "Button1", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
]