Skip to content

Commit

Permalink
Merge remote-tracking branch 'qc/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Sep 7, 2023
2 parents 9579ba9 + e25ffed commit 28796ed
Show file tree
Hide file tree
Showing 18 changed files with 601 additions and 3 deletions.
3 changes: 0 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

ecsls.url = "github:Sigmapitech-meta/ecsls";

qtile.url = "github:Sigmanificient/QtileConfig";
qtile.inputs.dotfiles.follows = "/";

home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down
6 changes: 6 additions & 0 deletions home/qtile/src/autostart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

[[ "$(hostname)" =~ 'Sigmachine' ]] \
&& xrandr --output HDMI-0 --right-of DP-1 --primary

notify-send "Welcome, $USER!" &
47 changes: 47 additions & 0 deletions home/qtile/src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from core import autostart, floating_layout, groups, keys, layouts, mouse, screens
from widgets import widget_defaults

extension_defaults = widget_defaults.copy()

dgroups_key_binder = None
dgroups_app_rules = []
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False

auto_fullscreen = True
focus_on_window_activation = "smart"
reconfigure_screens = True

# If things like steam games want to auto-minimize themselves when losing
# focus, should we respect this or not?
auto_minimize = False

# 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"

__all__ = (
# Hooks
"autostart",
# Keybindings
"keys",
# Mouse
"mouse",
# Workspaces groups
"groups",
# Layouts
"layouts",
"floating_layout",
# Screens
"screens",
# Widgets
"widget_defaults",
"extension_defaults",
)
23 changes: 23 additions & 0 deletions home/qtile/src/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from .groups import groups
from .hooks import autostart
from .keys import keys, mod
from .layouts import floating_layout, layouts
from .mouse import mouse
from .screens import screens

__all__ = (
# Keybindings
"keys",
"mod",
# Hooks
"autostart",
# Mouse
"mouse",
# Workspaces groups
"groups",
# Layouts
"layouts",
"floating_layout",
# Screens
"screens",
)
59 changes: 59 additions & 0 deletions home/qtile/src/core/bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os

from libqtile import bar, widget

from utils import Color
from widgets import (
Battery,
Clock,
CPUGraph,
GroupBox,
Memory,
Prompt,
QuickExit,
Separator,
TaskList,
Wakatime,
)


class Bar(bar.Bar):
instance_count: int = 0

widgets_checks = {
Battery: lambda _: os.uname().nodename == "Bacon",
}

_widgets = [
GroupBox,
Separator,
TaskList,
Separator,
Prompt,
Wakatime,
Battery,
Memory,
CPUGraph,
Separator,
widget.Volume,
Clock,
Separator,
QuickExit,
]

def __init__(self, id_):
self.id = id_

super().__init__(
widgets=self._build_widgets(),
size=24,
background=Color.BG_DARK.with_alpha(0.7),
margin=[0, 0, 8, 0],
)

def _build_widgets(self):
return [
widget_builder()
for widget_builder in self._widgets
if self.widgets_checks.get(widget_builder, bool)(self)
]
62 changes: 62 additions & 0 deletions home/qtile/src/core/groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from libqtile.config import DropDown, Group, Key, ScratchPad
from libqtile.lazy import lazy

from .keys import keys, mod

groups = [Group(f"{i}") for i in "ζδωχλξπσς"]
group_keys = [
"ampersand",
"eacute",
"quotedbl",
"apostrophe",
"parenleft",
"minus",
"egrave",
"underscore",
"agrave",
]

for g, key in zip(groups, group_keys):
keys.extend(
[
# mod1 + letter of group = switch to group
Key(
[mod],
key,
lazy.group[g.name].toscreen(),
desc="Switch to group {}".format(g.name),
),
Key(
[mod, "shift"],
key,
lazy.window.togroup(g.name, switch_group=True),
desc="Switch to & move focused window to group {}".format(
g.name
),
),
Key(
[mod],
"space",
lazy.group["scratchpad"].dropdown_toggle("term"),
),
]
)


groups.append(
ScratchPad(
"scratchpad",
[
DropDown(
"term",
"kitty",
x=0.05,
y=0.05,
opacity=0.95,
height=0.9,
width=0.9,
on_focus_lost_hide=False,
)
],
)
)
13 changes: 13 additions & 0 deletions home/qtile/src/core/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pathlib
import os
import subprocess

from libqtile import hook


@hook.subscribe.startup_once
def autostart():
cwd = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))
autostart_path = str((cwd / ".." / "autostart.sh").absolute())

subprocess.call([autostart_path])
88 changes: 88 additions & 0 deletions home/qtile/src/core/keys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from libqtile.config import Key
from libqtile.lazy import lazy

mod = "mod4"

keys = [
Key([mod], "e", lazy.spawn("thunar")),
Key([mod], "v", lazy.spawn("kitty -e pulsemixer")),
Key([mod], "h", lazy.spawn("kitty -e nmtui")),
Key([mod, "shift"], "v", lazy.spawn("pavucontrol")),
Key([mod], "l", lazy.spawn("betterlockscreen -l")),
Key([mod], "f", lazy.window.toggle_floating(), desc="Toggle floating"),
Key([mod], "b", lazy.spawn("firefox")),
Key([], "Print", lazy.spawn("flameshot gui --clipboard")),
Key(
[mod],
"space",
lazy.layout.next(),
desc="Move window focus to other window",
),
Key(
[mod, "shift"],
"h",
lazy.layout.shuffle_left(),
desc="Move window to the left",
),
Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
Key(
[mod, "shift"],
"Return",
lazy.layout.toggle_split(),
desc="Toggle between split and unsplit sides of stack",
),
Key([mod], "Return", lazy.spawn("kitty"), desc="Launch terminal"),
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
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",
),
# Backlight
Key([], "XF86MonBrightnessUp", lazy.spawn("brightnessctl set +5%")),
Key([], "XF86MonBrightnessDown", lazy.spawn("brightnessctl set 5%-")),
# Volume
Key([], "XF86AudioMute", lazy.spawn("pamixer --toggle-mute")),
Key([], "XF86AudioLowerVolume", lazy.spawn("pamixer --decrease 5")),
Key([], "XF86AudioRaiseVolume", lazy.spawn("pamixer --increase 5")),
Key(
[mod, "control"],
"Right",
lazy.layout.grow_right(),
lazy.layout.grow(),
lazy.layout.increase_ratio(),
lazy.layout.delete(),
desc="Increase active window size.",
),
Key(
[mod, "control"],
"Left",
lazy.layout.grow_left(),
lazy.layout.shrink(),
lazy.layout.decrease_ratio(),
lazy.layout.add(),
desc="Decrease active window size.",
),
Key(
[mod, "control"],
"Up",
lazy.layout.grow_up(),
lazy.layout.shrink(),
lazy.layout.decrease_ratio(),
lazy.layout.add(),
desc="Decrease active window size.",
),
Key(
[mod, "control"],
"Down",
lazy.layout.grow_down(),
lazy.layout.shrink(),
lazy.layout.decrease_ratio(),
lazy.layout.add(),
desc="Decrease active window size.",
),
]
31 changes: 31 additions & 0 deletions home/qtile/src/core/layouts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from libqtile import layout
from libqtile.config import Match

from utils import Color

layouts = [
layout.Columns(
border_width=2,
margin=4,
border_focus=Color.BLUE_DARK,
border_normal=Color.BG_DARK,
)
]

floating_layout = layout.Floating(
border_width=2,
border_focus=Color.BLUE_DARK,
border_normal=Color.BG_DARK,
float_rules=[
*layout.Floating.default_float_rules,
Match(wm_class="pavucontrol"), # gitk
Match(wm_class="confirmreset"), # gitk
Match(wm_class="makebranch"), # gitk
Match(wm_class="maketag"), # gitk
Match(wm_class="ssh-askpass"), # ssh-askpass
Match(title="branchdialog"), # gitk
Match(title="pinentry"), # GPG key password entry
Match(title="splash"), # .Idea loader
Match(title="kitty"),
],
)
24 changes: 24 additions & 0 deletions home/qtile/src/core/mouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from libqtile.config import Click, Drag
from libqtile.lazy import lazy

from core import mod

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], "Button3",
lazy.spawn("jgmenu_run"),
),
Click([mod], "Button2", lazy.window.bring_to_front()),
]
Loading

0 comments on commit 28796ed

Please sign in to comment.