QTile: Bluetooth keychords, prev/next gruops, suspend and lock with slock

This commit is contained in:
Joseph Ferano 2023-11-10 17:55:47 +07:00
parent b93d1344b5
commit ab01c6c240

View File

@ -33,7 +33,8 @@ from Xlib import display as xdisplay
from typing import Callable from typing import Callable
from libqtile import bar, layout, widget from libqtile import bar, layout, widget
from libqtile.config import Click, Drag, Group, Key, Match, Screen from libqtile.widget import Chord
from libqtile.config import Click, Drag, Group, Key, Match, Screen, KeyChord
from libqtile.lazy import lazy from libqtile.lazy import lazy
from libqtile.utils import guess_terminal from libqtile.utils import guess_terminal
from libqtile.log_utils import logger from libqtile.log_utils import logger
@ -73,8 +74,19 @@ keys = [
Key([mod], "l", lazy.layout.right().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), Key([mod], "l", lazy.layout.right().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"),
Key([alt], "tab", lazy.layout.next(), desc="Move window focus to other window"), Key([alt], "tab", lazy.layout.next(), desc="Move window focus to other window"),
Key([mod], "tab", lazy.screen.toggle_group(), desc="Toggle Group"), Key([mod], "tab", lazy.screen.toggle_group(), desc="Toggle Group"),
Key([mod], "space", lazy.spawn("rofi -show drun"), desc="Open Rofi"), # Eventually we should switch back to emacs app launcher
Key([mod], "space", lazy.spawn("rofi -show drun -theme Arc-Dark.rasi"), desc="Open Rofi"),
KeyChord([mod], "b", [
Key([], "c", lazy.spawn("bluetoothctl connect F8:5B:6E:2A:6A:CF &>/dev/null",
shell=True)),
Key([], "d", lazy.spawn("bluetoothctl disconnect F8:5B:6E:2A:6A:CF &>/dev/null",
shell=True)),
Key([], "r", lazy.spawn("bluetoothctl scan on && sleep 1 && bluetoothctl connect F8:5B:6E:2A:6A:CF && sleep 2 && bluetoothctl scan off",
shell=True)),
Key([], "t", lazy.spawn("toggle-bt-codec",
shell=True)),
]),
# Move windows between left/right columns or move up/down in current stack. # Move windows between left/right columns or move up/down in current stack.
# Moving out of range in Columns layout will create new column. # Moving out of range in Columns layout will create new column.
Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window to the left"), Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window to the left"),
@ -88,8 +100,11 @@ keys = [
Key([mod, "control"], "j", lazy.layout.grow_down(), desc="Grow window down"), Key([mod, "control"], "j", lazy.layout.grow_down(), desc="Grow window down"),
Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"), Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"),
# Key([mod], "d", lazy.groups.use_previous_layout(), desc="Move focus to left"), Key([mod], "comma", lazy.screen.prev_group(), desc="Move to previous group"),
# Key([mod], "a", lazy.layout.use_next_layout(), desc="Move focus to left"), Key([mod], "period", lazy.screen.next_group(), desc="Move to next group"),
Key([mod, "shift"], "comma", lazy.prev_screen(), desc="Move focus to left screen"),
Key([mod, "shift"], "period", lazy.next_screen(), desc="Move focus to left screen"),
Key([mod], "w", lazy.next_layout(), desc="Toggle between layouts"),
# TODO: Figure out another binding for this # TODO: Figure out another binding for this
# Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"), # Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
@ -98,6 +113,8 @@ keys = [
# Split = all windows displayed # Split = all windows displayed
# Unsplit = 1 window displayed, like Max layout, but still with # Unsplit = 1 window displayed, like Max layout, but still with
# multiple stack panes # multiple stack panes
Key([mod, "control", "shift"], "l",
lazy.spawn("slock | systemctl suspend", shell=True), desc="Slock and suspend"),
Key( Key(
[mod, "shift"], [mod, "shift"],
"Return", "Return",
@ -153,7 +170,7 @@ def get_num_monitors():
number_of_monitors += 1 number_of_monitors += 1
except Exception as e: except Exception as e:
# always setup at least one monitor # always setup at least one monitor
logger.warning(e) logger.error(e)
return 1 return 1
else: else:
return number_of_monitors return number_of_monitors
@ -173,10 +190,9 @@ screens = [
Screen( Screen(
wallpaper=pape, wallpaper=pape,
wallpaper_mode='fill', wallpaper_mode='fill',
top=bar.Bar( top=bar.Bar([
[ group_box, current_layout, prompt, window_name,
group_box, current_layout, prompt, window_name, chord, systray, chord, volume, battery, clock,
systray, volume, battery, clock,
], ],
24, 24,
# border_width=[2, 0, 2, 0], # Draw top and bottom borders # border_width=[2, 0, 2, 0], # Draw top and bottom borders
@ -187,7 +203,6 @@ screens = [
groups = [Group(i) for i in "123456789"] groups = [Group(i) for i in "123456789"]
num_monitors = get_num_monitors() num_monitors = get_num_monitors()
logger.warning(num_monitors)
if num_monitors > 1: if num_monitors > 1:
side_screen = Screen( side_screen = Screen(
wallpaper=pape, wallpaper=pape,