From 84b556331e481edb8d493dda63890c8682647e86 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 10 Feb 2023 20:58:37 +0200 Subject: qtile: Simplify keys --- .config/qtile/config.py | 155 +++++++++++++++++++++- .config/qtile/keys.py | 169 ------------------------ Qtile.org | 338 ++++++++++++++++++++++-------------------------- 3 files changed, 308 insertions(+), 354 deletions(-) delete mode 100644 .config/qtile/keys.py diff --git a/.config/qtile/config.py b/.config/qtile/config.py index a128fd5..ed0491b 100644 --- a/.config/qtile/config.py +++ b/.config/qtile/config.py @@ -1,3 +1,152 @@ +from libqtile.config import Key +from libqtile.command import lazy +from libqtile.config import Click, Drag + + +mod = "mod4" +mod = "mod4" +browser = "firefox" +term = "emacsclient -c" +editor = "emacsclient -c -a 'emacs'" + +keys = [ + Key([mod], "Return", + lazy.spawn(term), + ), + Key([mod, "shift"], "a", + lazy.spawn('anki'), + ), + Key([mod, "shift"], "m", + lazy.spawn("spotify"), + ), + Key([mod], "Tab", + lazy.spawn("rofi -show drun"), + ), + Key([mod], "r", + lazy.spawn("rofi -show run"), + ), + Key([mod], "w", + lazy.spawn("rofi -show window"), + ), + Key([mod], "p", + lazy.spawn("passmenu -p 'Password for: '"), + ), + Key([mod], "b", + lazy.spawn(browser), + ), + Key([mod, "shift"], "c", + lazy.next_layout(), + ), + Key([mod], "q", + lazy.window.kill(), + ), + Key([mod, "shift"], "r", + lazy.restart(), + ), + Key([mod, "shift"], "0", + lazy.shutdown(), + ), + Key([mod, "shift"], "e", + lazy.spawn(editor), + ), + # Switch focus of monitors + Key([mod], "period", + lazy.next_screen(), + ), + # Treetab controls + Key([mod, "shift"], "h", + lazy.layout.move_left(), + ), + Key([mod, "shift"], "l", + lazy.layout.move_right(), + ), + # Window controls + Key([mod], "n", + lazy.layout.down(), + ), + Key([mod], "p", + lazy.layout.up(), + ), + Key([mod, "shift"], "n", + lazy.layout.shuffle_down(), + lazy.layout.section_down(), + ), + Key([mod, "shift"], "p", + lazy.layout.shuffle_up(), + lazy.layout.section_up(), + ), + Key([mod], "s", + lazy.layout.shrink(), + lazy.layout.decrease_nmaster(), + ), + Key([mod], "l", + lazy.layout.grow(), + lazy.layout.increase_nmaster(), + ), + Key([mod], "o", + lazy.layout.normalize(), + ), + Key([mod], "m", + lazy.layout.maximize(), + ), + Key([mod, "shift"], "f", + lazy.window.toggle_floating(), + ), + Key([mod], "f", + lazy.window.toggle_fullscreen(), + ), + # Stack controls + Key([mod, "shift"], "Tab", + lazy.layout.rotate(), + lazy.layout.flip(), + ), + Key([mod, "shift"], "space", + lazy.layout.toggle_split(), + ), + # Volume controls + Key([], "XF86AudioLowerVolume", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([], "XF86AudioRaiseVolume", + lazy.spawn('amixer sset Master 5%+'), + ), + # I use mod+F[key] to change volume in my thinkpad, + # as I dislike using "fn" key in laptops + Key([mod], "F11", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([mod], "F12", + lazy.spawn('amixer sset Master 5%+'), + ), + # Music controls | MOC + Key([mod], "u", + lazy.spawn("mocp -G "), + ), + Key([mod], "o", + lazy.spawn("mocp -f"), + ), + Key([mod], "i", + lazy.spawn("mocp -r"), + ), + # Change languages + Key([mod], "F1", + lazy.spawn("setxkbmap us -option ctrl:swapcaps"), + ), + Key([mod], "F2", + lazy.spawn("setxkbmap gr"), + ), +] + + +mouse = [ + Drag([mod], "Button1", lazy.window.set_position_floating(), + start=lazy.window.get_position()), + Drag([mod], "Button3", lazy.window.set_size_floating(), + start=lazy.window.get_size()), + Click([mod], "Button2", + lazy.window.bring_to_front()), + ] + """Configuration for qtile.""" import os @@ -5,7 +154,6 @@ import subprocess from libqtile import layout, bar, widget, hook from libqtile.config import Group, Screen from libqtile.dgroups import simple_key_binder -from keys import MyKeys from colors import dracula @@ -16,15 +164,12 @@ def start_once(): subprocess.run([autostart_path]) -# Keybindings -my_keys = MyKeys() -keys = my_keys.init_keys() # Use this to change between workspaces dgroups_key_binder = simple_key_binder("mod4") -mouse = my_keys.init_mouse() + # Groups and layouts groups = [] diff --git a/.config/qtile/keys.py b/.config/qtile/keys.py deleted file mode 100644 index 477c164..0000000 --- a/.config/qtile/keys.py +++ /dev/null @@ -1,169 +0,0 @@ -from libqtile.config import Key -from libqtile.command import lazy -from libqtile.config import Click, Drag - - -class MyKeys(): - """ - Emacs-like keybindings for qtile - I prefer having my keys seperated so I won't mess anything up, - especially if you are running the same config in different machines - """ - - def __init__(self): - """ - Default customization - """ - self.mod = "mod4" - self.browser = "firefox" - self.term = "emacsclient -c" - self.editor = "emacsclient -c -a 'emacs'" - - def init_keys(self): - """ - Keyboard keybindings | Emacs-like | Set them and forget them. - - I'm used to having the superkey to control my window manager, - and control for my emacs. - """ - my_keys = [ - Key([self.mod], "Return", - lazy.spawn(self.term), - ), - Key([self.mod, "shift"], "a", - lazy.spawn('anki'), - ), - Key([self.mod, "shift"], "m", - lazy.spawn("spotify"), - ), - Key([self.mod], "Tab", - lazy.spawn("rofi -show drun"), - ), - Key([self.mod], "r", - lazy.spawn("rofi -show run"), - ), - Key([self.mod], "w", - lazy.spawn("rofi -show window"), - ), - Key([self.mod], "p", - lazy.spawn("passmenu -p 'Password for: '"), - ), - Key([self.mod], "b", - lazy.spawn(self.browser), - ), - Key([self.mod, "shift"], "c", - lazy.next_layout(), - ), - Key([self.mod], "q", - lazy.window.kill(), - ), - Key([self.mod, "shift"], "r", - lazy.restart(), - ), - Key([self.mod, "shift"], "0", - lazy.shutdown(), - ), - Key([self.mod, "shift"], "e", - lazy.spawn(self.editor), - ), - # Switch focus of monitors - Key([self.mod], "period", - lazy.next_screen(), - ), - # Treetab controls - Key([self.mod, "shift"], "h", - lazy.layout.move_left(), - ), - Key([self.mod, "shift"], "l", - lazy.layout.move_right(), - ), - # Window controls - Key([self.mod], "n", - lazy.layout.down(), - ), - Key([self.mod], "p", - lazy.layout.up(), - ), - Key([self.mod, "shift"], "n", - lazy.layout.shuffle_down(), - lazy.layout.section_down(), - ), - Key([self.mod, "shift"], "p", - lazy.layout.shuffle_up(), - lazy.layout.section_up(), - ), - Key([self.mod], "s", - lazy.layout.shrink(), - lazy.layout.decrease_nmaster(), - ), - Key([self.mod], "l", - lazy.layout.grow(), - lazy.layout.increase_nmaster(), - ), - Key([self.mod], "o", - lazy.layout.normalize(), - ), - Key([self.mod], "m", - lazy.layout.maximize(), - ), - Key([self.mod, "shift"], "f", - lazy.window.toggle_floating(), - ), - Key([self.mod], "f", - lazy.window.toggle_fullscreen(), - ), - # Stack controls - Key([self.mod, "shift"], "Tab", - lazy.layout.rotate(), - lazy.layout.flip(), - ), - Key([self.mod, "shift"], "space", - lazy.layout.toggle_split(), - ), - # Volume controls - Key([], "XF86AudioLowerVolume", - lazy.spawn('amixer sset Master 5%-'), - ), - Key([], "XF86AudioRaiseVolume", - lazy.spawn('amixer sset Master 5%+'), - ), - # I use mod+F[key] to change volume in my thinkpad, - # as I dislike using "fn" key in laptops - Key([self.mod], "F11", - lazy.spawn('amixer sset Master 5%-'), - ), - Key([self.mod], "F12", - lazy.spawn('amixer sset Master 5%+'), - ), - # Music controls | MOC - Key([self.mod], "u", - lazy.spawn("mocp -G "), - ), - Key([self.mod], "o", - lazy.spawn("mocp -f"), - ), - Key([self.mod], "i", - lazy.spawn("mocp -r"), - ), - # Change languages - Key([self.mod], "F1", - lazy.spawn("setxkbmap us -option ctrl:swapcaps"), - ), - Key([self.mod], "F2", - lazy.spawn("setxkbmap gr"), - ), - ] - - return my_keys - - def init_mouse(self): - """Mouse keys | cause sometimes we have to use the mouse.""" - mouse_keys = [ - Drag([self.mod], "Button1", lazy.window.set_position_floating(), - start=lazy.window.get_position()), - Drag([self.mod], "Button3", lazy.window.set_size_floating(), - start=lazy.window.get_size()), - Click([self.mod], "Button2", - lazy.window.bring_to_front()), - ] - return mouse_keys diff --git a/Qtile.org b/Qtile.org index 1857fdf..878df7b 100644 --- a/Qtile.org +++ b/Qtile.org @@ -2,11 +2,11 @@ #+auto_tangle: t * Table of contents :toc: - [[#colors][Colors]] -- [[#base][Base]] - [[#keys][Keys]] +- [[#base][Base]] * Colors -#+begin_src python :tangle .config/qtile/colors.py +#+begin_src python :tangle .config/qtile/colors.by """ My Favorite Color Themes For Qtile | @@ -67,6 +67,161 @@ "orange": "#FBA922", } #+end_src +* Keys +#+begin_src python :tangle .config/qtile/config.py + from libqtile.config import Key + from libqtile.command import lazy + from libqtile.config import Click, Drag + + + mod = "mod4" + mod = "mod4" + browser = "firefox" + term = "emacsclient -c" + editor = "emacsclient -c -a 'emacs'" + + keys = [ + Key([mod], "Return", + lazy.spawn(term), + ), + Key([mod, "shift"], "a", + lazy.spawn('anki'), + ), + Key([mod, "shift"], "m", + lazy.spawn("spotify"), + ), + Key([mod], "Tab", + lazy.spawn("rofi -show drun"), + ), + Key([mod], "r", + lazy.spawn("rofi -show run"), + ), + Key([mod], "w", + lazy.spawn("rofi -show window"), + ), + Key([mod], "p", + lazy.spawn("passmenu -p 'Password for: '"), + ), + Key([mod], "b", + lazy.spawn(browser), + ), + Key([mod, "shift"], "c", + lazy.next_layout(), + ), + Key([mod], "q", + lazy.window.kill(), + ), + Key([mod, "shift"], "r", + lazy.restart(), + ), + Key([mod, "shift"], "0", + lazy.shutdown(), + ), + Key([mod, "shift"], "e", + lazy.spawn(editor), + ), + # Switch focus of monitors + Key([mod], "period", + lazy.next_screen(), + ), + # Treetab controls + Key([mod, "shift"], "h", + lazy.layout.move_left(), + ), + Key([mod, "shift"], "l", + lazy.layout.move_right(), + ), + # Window controls + Key([mod], "n", + lazy.layout.down(), + ), + Key([mod], "p", + lazy.layout.up(), + ), + Key([mod, "shift"], "n", + lazy.layout.shuffle_down(), + lazy.layout.section_down(), + ), + Key([mod, "shift"], "p", + lazy.layout.shuffle_up(), + lazy.layout.section_up(), + ), + Key([mod], "s", + lazy.layout.shrink(), + lazy.layout.decrease_nmaster(), + ), + Key([mod], "l", + lazy.layout.grow(), + lazy.layout.increase_nmaster(), + ), + Key([mod], "o", + lazy.layout.normalize(), + ), + Key([mod], "m", + lazy.layout.maximize(), + ), + Key([mod, "shift"], "f", + lazy.window.toggle_floating(), + ), + Key([mod], "f", + lazy.window.toggle_fullscreen(), + ), + # Stack controls + Key([mod, "shift"], "Tab", + lazy.layout.rotate(), + lazy.layout.flip(), + ), + Key([mod, "shift"], "space", + lazy.layout.toggle_split(), + ), + # Volume controls + Key([], "XF86AudioLowerVolume", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([], "XF86AudioRaiseVolume", + lazy.spawn('amixer sset Master 5%+'), + ), + # I use mod+F[key] to change volume in my thinkpad, + # as I dislike using "fn" key in laptops + Key([mod], "F11", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([mod], "F12", + lazy.spawn('amixer sset Master 5%+'), + ), + # Music controls | MOC + Key([mod], "u", + lazy.spawn("mocp -G "), + ), + Key([mod], "o", + lazy.spawn("mocp -f"), + ), + Key([mod], "i", + lazy.spawn("mocp -r"), + ), + # Change languages + Key([mod], "F1", + lazy.spawn("setxkbmap us -option ctrl:swapcaps"), + ), + Key([mod], "F2", + lazy.spawn("setxkbmap gr"), + ), + ] + + + mouse = [ + Drag([mod], "Button1", lazy.window.set_position_floating(), + start=lazy.window.get_position()), + Drag([mod], "Button3", lazy.window.set_size_floating(), + start=lazy.window.get_size()), + Click([mod], "Button2", + lazy.window.bring_to_front()), + ] + + + +#+end_src + * Base #+begin_src python :tangle .config/qtile/config.py """Configuration for qtile.""" @@ -76,7 +231,6 @@ from libqtile import layout, bar, widget, hook from libqtile.config import Group, Screen from libqtile.dgroups import simple_key_binder - from keys import MyKeys from colors import dracula @@ -87,15 +241,12 @@ subprocess.run([autostart_path]) - # Keybindings - my_keys = MyKeys() - keys = my_keys.init_keys() # Use this to change between workspaces dgroups_key_binder = simple_key_binder("mod4") - mouse = my_keys.init_mouse() + # Groups and layouts groups = [] @@ -361,176 +512,3 @@ focus_on_window_activation = "smart" # or focus wmname = "Qtile-Apo11o" #+end_src - -* Keys -#+begin_src python :tangle .config/qtile/keys.py - from libqtile.config import Key - from libqtile.command import lazy - from libqtile.config import Click, Drag - - - class MyKeys(): - """ - Emacs-like keybindings for qtile - I prefer having my keys seperated so I won't mess anything up, - especially if you are running the same config in different machines - """ - - def __init__(self): - """ - Default customization - """ - self.mod = "mod4" - self.browser = "firefox" - self.term = "emacsclient -c" - self.editor = "emacsclient -c -a 'emacs'" - - def init_keys(self): - """ - Keyboard keybindings | Emacs-like | Set them and forget them. - - I'm used to having the superkey to control my window manager, - and control for my emacs. - """ - my_keys = [ - Key([self.mod], "Return", - lazy.spawn(self.term), - ), - Key([self.mod, "shift"], "a", - lazy.spawn('anki'), - ), - Key([self.mod, "shift"], "m", - lazy.spawn("spotify"), - ), - Key([self.mod], "Tab", - lazy.spawn("rofi -show drun"), - ), - Key([self.mod], "r", - lazy.spawn("rofi -show run"), - ), - Key([self.mod], "w", - lazy.spawn("rofi -show window"), - ), - Key([self.mod], "p", - lazy.spawn("passmenu -p 'Password for: '"), - ), - Key([self.mod], "b", - lazy.spawn(self.browser), - ), - Key([self.mod, "shift"], "c", - lazy.next_layout(), - ), - Key([self.mod], "q", - lazy.window.kill(), - ), - Key([self.mod, "shift"], "r", - lazy.restart(), - ), - Key([self.mod, "shift"], "0", - lazy.shutdown(), - ), - Key([self.mod, "shift"], "e", - lazy.spawn(self.editor), - ), - # Switch focus of monitors - Key([self.mod], "period", - lazy.next_screen(), - ), - # Treetab controls - Key([self.mod, "shift"], "h", - lazy.layout.move_left(), - ), - Key([self.mod, "shift"], "l", - lazy.layout.move_right(), - ), - # Window controls - Key([self.mod], "n", - lazy.layout.down(), - ), - Key([self.mod], "p", - lazy.layout.up(), - ), - Key([self.mod, "shift"], "n", - lazy.layout.shuffle_down(), - lazy.layout.section_down(), - ), - Key([self.mod, "shift"], "p", - lazy.layout.shuffle_up(), - lazy.layout.section_up(), - ), - Key([self.mod], "s", - lazy.layout.shrink(), - lazy.layout.decrease_nmaster(), - ), - Key([self.mod], "l", - lazy.layout.grow(), - lazy.layout.increase_nmaster(), - ), - Key([self.mod], "o", - lazy.layout.normalize(), - ), - Key([self.mod], "m", - lazy.layout.maximize(), - ), - Key([self.mod, "shift"], "f", - lazy.window.toggle_floating(), - ), - Key([self.mod], "f", - lazy.window.toggle_fullscreen(), - ), - # Stack controls - Key([self.mod, "shift"], "Tab", - lazy.layout.rotate(), - lazy.layout.flip(), - ), - Key([self.mod, "shift"], "space", - lazy.layout.toggle_split(), - ), - # Volume controls - Key([], "XF86AudioLowerVolume", - lazy.spawn('amixer sset Master 5%-'), - ), - Key([], "XF86AudioRaiseVolume", - lazy.spawn('amixer sset Master 5%+'), - ), - # I use mod+F[key] to change volume in my thinkpad, - # as I dislike using "fn" key in laptops - Key([self.mod], "F11", - lazy.spawn('amixer sset Master 5%-'), - ), - Key([self.mod], "F12", - lazy.spawn('amixer sset Master 5%+'), - ), - # Music controls | MOC - Key([self.mod], "u", - lazy.spawn("mocp -G "), - ), - Key([self.mod], "o", - lazy.spawn("mocp -f"), - ), - Key([self.mod], "i", - lazy.spawn("mocp -r"), - ), - # Change languages - Key([self.mod], "F1", - lazy.spawn("setxkbmap us -option ctrl:swapcaps"), - ), - Key([self.mod], "F2", - lazy.spawn("setxkbmap gr"), - ), - ] - - return my_keys - - def init_mouse(self): - """Mouse keys | cause sometimes we have to use the mouse.""" - mouse_keys = [ - Drag([self.mod], "Button1", lazy.window.set_position_floating(), - start=lazy.window.get_position()), - Drag([self.mod], "Button3", lazy.window.set_size_floating(), - start=lazy.window.get_size()), - Click([self.mod], "Button2", - lazy.window.bring_to_front()), - ] - return mouse_keys -#+end_src -- cgit v1.2.3