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 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.utils import guess_terminal
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([alt], "tab", lazy.layout.next(), desc="Move window focus to other window"),
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.
# 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"),
@ -88,8 +100,11 @@ keys = [
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], "d", lazy.groups.use_previous_layout(), desc="Move focus to left"),
# Key([mod], "a", lazy.layout.use_next_layout(), desc="Move focus to left"),
Key([mod], "comma", lazy.screen.prev_group(), desc="Move to previous group"),
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
# Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
@ -98,6 +113,8 @@ keys = [
# Split = all windows displayed
# Unsplit = 1 window displayed, like Max layout, but still with
# multiple stack panes
Key([mod, "control", "shift"], "l",
lazy.spawn("slock | systemctl suspend", shell=True), desc="Slock and suspend"),
Key(
[mod, "shift"],
"Return",
@ -153,7 +170,7 @@ def get_num_monitors():
number_of_monitors += 1
except Exception as e:
# always setup at least one monitor
logger.warning(e)
logger.error(e)
return 1
else:
return number_of_monitors
@ -173,10 +190,9 @@ screens = [
Screen(
wallpaper=pape,
wallpaper_mode='fill',
top=bar.Bar(
[
group_box, current_layout, prompt, window_name, chord,
systray, volume, battery, clock,
top=bar.Bar([
group_box, current_layout, prompt, window_name,
systray, chord, volume, battery, clock,
],
24,
# border_width=[2, 0, 2, 0], # Draw top and bottom borders
@ -187,7 +203,6 @@ screens = [
groups = [Group(i) for i in "123456789"]
num_monitors = get_num_monitors()
logger.warning(num_monitors)
if num_monitors > 1:
side_screen = Screen(
wallpaper=pape,