clean up code

This commit is contained in:
zoe 2022-09-08 10:13:37 +02:00
parent 0265daf7c8
commit fac7a898bd
3 changed files with 103 additions and 79 deletions

View File

@ -1,83 +1,21 @@
from libqtile.config import Click, Drag, Group, Key
from libqtile.lazy import lazy
from libqtile import hook
import autostart
import my_layouts
import my_widgets
import my_functions
import my_keys
import my_globals
mod = "mod4"
terminal = "kitty"
mod = my_globals.mod
terminal = my_globals.terminal
screens = my_widgets.get_screens()
keys = [
# A list of available commands that can be bound to keys can be found
# at https://docs.qtile.org/en/latest/manual/config/lazy.html
# Switch between screens
Key(
[mod],
"q",
lazy.next_screen(),
),
Key([mod], "h", lazy.layout.left(), desc="Move focus to left"),
Key([mod], "l", lazy.layout.right(), desc="Move focus to right"),
Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
Key([mod], "space", lazy.layout.next(), desc="Move window focus to other window"),
# 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"
),
Key(
[mod, "shift"],
"l",
lazy.layout.shuffle_right(),
desc="Move window to the right",
),
Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down"),
Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"),
# Grow windows. If current window is on the edge of screen and direction
# will be to screen edge - window would shrink.
Key([mod, "control"], "h", lazy.layout.grow_left(), desc="Grow window to the left"),
Key(
[mod, "control"], "l", lazy.layout.grow_right(), desc="Grow window to the right"
),
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], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
# Toggle between split and unsplit sides of stack.
# Split = all windows displayed
# Unsplit = 1 window displayed, like Max layout, but still with
# multiple stack panes
Key(
[mod, "shift"],
"Return",
lazy.layout.toggle_split(),
desc="Toggle between split and unsplit sides of stack",
),
Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"),
# Toggle between different layouts as defined below
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
Key([mod], "f", lazy.window.toggle_fullscreen()),
Key([mod], "t", lazy.window.toggle_floating()),
Key([mod, "shift"], "t", my_functions.set_all_float_windows_to_non_floating_mode()),
Key([mod], "w", lazy.window.kill(), desc="Kill focused window"),
Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"),
Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"),
Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"),
Key(
[mod],
"d",
lazy.spawn(
"rofi -combi-modi window,drun,scripts,ssh, -show-icons -show combi -modi combi"
),
desc="rofi",
),
]
keys = my_keys.get_defaults()
groups = [Group(i) for i in "123456789"]
@ -139,18 +77,10 @@ reconfigure_screens = True
# focus, should we respect this or not?
auto_minimize = False
# When using the Wayland backend, this can be used to configure input devices.
wl_input_rules = None
# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
# string besides java UI toolkits; you can see several discussions on the
# mailing lists, GitHub issues, and other WM documentation that suggest setting
# this string if your java app doesn't work correctly. We may as well just lie
# and say that we're a working one by default.
#
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
# java that happens to be on java's whitelist.
wmname = "LG3D"
# autostart
autostart.start_all()
@hook.subscribe.startup_once
def start_once():
autostart.start_all()

View File

@ -17,3 +17,5 @@ colors = {
border_width = 2
gap_width = 8
terminal = "kitty"
mod = "mod4"

92
my_keys.py Normal file
View File

@ -0,0 +1,92 @@
from libqtile.config import Key
from libqtile.lazy import lazy
import my_functions
import my_globals
def get_defaults():
mod, terminal = my_globals.mod, my_globals.terminal
return [
# A list of available commands that can be bound to keys can be found
# at https://docs.qtile.org/en/latest/manual/config/lazy.html
# Switch between screens
Key(
[mod],
"q",
lazy.next_screen(),
),
Key([mod], "h", lazy.layout.left(), desc="Move focus to left"),
Key([mod], "l", lazy.layout.right(), desc="Move focus to right"),
Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
Key(
[mod], "space", lazy.layout.next(), desc="Move window focus to other window"
),
# 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",
),
Key(
[mod, "shift"],
"l",
lazy.layout.shuffle_right(),
desc="Move window to the right",
),
Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down"),
Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"),
# Grow windows. If current window is on the edge of screen and direction
# will be to screen edge - window would shrink.
Key(
[mod, "control"],
"h",
lazy.layout.grow_left(),
desc="Grow window to the left",
),
Key(
[mod, "control"],
"l",
lazy.layout.grow_right(),
desc="Grow window to the right",
),
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], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
# Toggle between split and unsplit sides of stack.
# Split = all windows displayed
# Unsplit = 1 window displayed, like Max layout, but still with
# multiple stack panes
Key(
[mod, "shift"],
"Return",
lazy.layout.toggle_split(),
desc="Toggle between split and unsplit sides of stack",
),
Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"),
# Toggle between different layouts as defined below
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
Key([mod], "f", lazy.window.toggle_fullscreen()),
Key([mod], "t", lazy.window.toggle_floating()),
Key(
[mod, "shift"],
"t",
my_functions.set_all_float_windows_to_non_floating_mode(),
),
Key([mod], "w", lazy.window.kill(), desc="Kill focused window"),
Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"),
Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"),
Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"),
Key(
[mod],
"d",
lazy.spawn(
"rofi -combi-modi window,drun,scripts,ssh, -show-icons -show combi -modi combi"
),
desc="rofi",
),
]