From 9c40a693e8982033bc78b40080a959e4bd1ff9d6 Mon Sep 17 00:00:00 2001 From: atagen Date: Thu, 25 Jan 2024 01:30:13 +1100 Subject: [PATCH] switch to avizo for xf86 buttons --- flake.lock | 194 +++++------------------------------ flake.nix | 12 +-- home/dots/qtile/autostart.sh | 1 + home/dots/qtile/config.py | 71 +++++-------- home/dots/qtile/lib.py | 53 ++++++++++ home/home.nix | 33 +++++- home/programs/qtile.nix | 3 + system/configuration.nix | 4 + util/rice.nix | 4 +- 9 files changed, 151 insertions(+), 224 deletions(-) create mode 100644 home/dots/qtile/lib.py diff --git a/flake.lock b/flake.lock index 68a54f8..81159be 100644 --- a/flake.lock +++ b/flake.lock @@ -128,11 +128,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -195,42 +195,6 @@ "type": "github" } }, - "flake-utils_5": { - "inputs": { - "systems": "systems_5" - }, - "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_6": { - "inputs": { - "systems": "systems_6" - }, - "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "gitignore": { "inputs": { "nixpkgs": [ @@ -263,11 +227,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1704986785, - "narHash": "sha256-h0/pFRsnFesY+u+0EmeOXcReN8uF6Z3ok+eByZIks8E=", + "lastModified": 1706079621, + "narHash": "sha256-grxw04yyeod5OMujsQ+xXCLP/DYMrFzLW5NqIteTGhY=", "owner": "helix-editor", "repo": "helix", - "rev": "17dd102e5cccbb2a9a0f0224af63e52f3dab846b", + "rev": "83f09ecbff5160e4350c8099be1ad4c64513f665", "type": "github" }, "original": { @@ -283,11 +247,11 @@ ] }, "locked": { - "lastModified": 1704980804, - "narHash": "sha256-lPNNKdPqIYcjhhYIVwlajNt/HqVWbMOoSdNnwCvOP04=", + "lastModified": 1706080884, + "narHash": "sha256-qhxisCrSraN5YWVb0lNCFH8ovqnCw5W9ldac4Dzr0Nw=", "owner": "nix-community", "repo": "home-manager", - "rev": "93e804e7f8a1eb88bde6117cd5046501e66aa4bd", + "rev": "6b28ab2d798c1c84e24053d95f4ee1dd9d81e2fb", "type": "github" }, "original": { @@ -319,11 +283,11 @@ ] }, "locked": { - "lastModified": 1704596958, - "narHash": "sha256-BK3Ohsz7m8X6qVKFxDtr8KVcHipfr5hYE9PDIJevHbQ=", + "lastModified": 1705806513, + "narHash": "sha256-FcOmNjhHFfPz2udZbRpZ1sfyhVMr+C2O8kOxPj+HDDk=", "owner": "Mic92", "repo": "nix-index-database", - "rev": "f46800ac5a6e9f892fe36e50821c5d85794ecc62", + "rev": "f8e04fbcebcc24cebc91989981bd45f69b963ed7", "type": "github" }, "original": { @@ -397,11 +361,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1704982974, - "narHash": "sha256-BqRhnQLq+iKeHg0z7UIq/IprLF3tluci02ek4ZH7rpc=", + "lastModified": 1706080410, + "narHash": "sha256-95IUdm3/U4XH2C8lsp4wM8wK8JH29GvM7RekrBlDeus=", "owner": "nix-community", "repo": "nixd", - "rev": "ad23935dff90f7c30d02bfbcaeb39ea17f2b4e77", + "rev": "c7d27327183e3d66b88ba672857ad222169cff32", "type": "github" }, "original": { @@ -545,11 +509,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1704722960, - "narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=", + "lastModified": 1705856552, + "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d", + "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", "type": "github" }, "original": { @@ -559,29 +523,13 @@ "type": "github" } }, - "nixpkgs_4": { - "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nur": { "locked": { - "lastModified": 1705031957, - "narHash": "sha256-ODY28iYgvHmEjSwiyMRblQh0zADp0g6lb5eTpH3DAeY=", + "lastModified": 1706101139, + "narHash": "sha256-hgi7/n5nHk/ezZZlm+qHGSYPuQ+0mh4A6C73YOd1sZA=", "owner": "nix-community", "repo": "NUR", - "rev": "1a43e4b9c02d33694e9d1d0d7a9423fb9b17a947", + "rev": "a5e13eca3f756dc47e9587393e7eddfa27dda818", "type": "github" }, "original": { @@ -674,11 +622,11 @@ "qtile-src": { "flake": false, "locked": { - "lastModified": 1705005377, - "narHash": "sha256-PbVe93exSfEzQaKklpk2jieo+aXNbGVaV1cyWi8zh9w=", + "lastModified": 1705779990, + "narHash": "sha256-mgMRkoKT0Gp5/OfVQbkeDTkg9QRFn4PU3ziM5E6V+oI=", "owner": "qtile", "repo": "qtile", - "rev": "6f1986f7a348ed9c044c3b2303a06189d6393558", + "rev": "2b5ad3c5976052199adf154555384919c6d0aba2", "type": "github" }, "original": { @@ -701,8 +649,7 @@ "nixpkgs-stable": "nixpkgs-stable_2", "nur": "nur", "qtile": "qtile", - "rust-overlay": "rust-overlay_2", - "swayosd": "swayosd" + "rust-overlay": "rust-overlay_2" } }, "rust-overlay": { @@ -740,11 +687,11 @@ ] }, "locked": { - "lastModified": 1705025860, - "narHash": "sha256-9vcqo5CJLOHU63S7pVlP0u4OhgJxrXebQR4vqMPXLRg=", + "lastModified": 1706062676, + "narHash": "sha256-aIgYdyQyKRHZ8gSmke3DE09D5ypK4tP+XYqrKPAd/3M=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d458975da373a37422577886566fce8201bc1254", + "rev": "81eb4bdb219d97d749f152eb4de6a081b088b08d", "type": "github" }, "original": { @@ -753,61 +700,6 @@ "type": "github" } }, - "rust-overlay_3": { - "inputs": { - "flake-utils": "flake-utils_6", - "nixpkgs": "nixpkgs_4" - }, - "locked": { - "lastModified": 1705025860, - "narHash": "sha256-9vcqo5CJLOHU63S7pVlP0u4OhgJxrXebQR4vqMPXLRg=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "d458975da373a37422577886566fce8201bc1254", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "swayosd": { - "inputs": { - "flake-utils": "flake-utils_5", - "nixpkgs": [ - "nixpkgs" - ], - "rust-overlay": "rust-overlay_3", - "swayosd-src": "swayosd-src" - }, - "locked": { - "lastModified": 1, - "narHash": "sha256-2A4xxc3t3TS7NGYJWS9tXHPlBI0MXAmYPIAgMHDNIJ4=", - "path": "flakes/swayosd", - "type": "path" - }, - "original": { - "path": "flakes/swayosd", - "type": "path" - } - }, - "swayosd-src": { - "flake": false, - "locked": { - "lastModified": 1702248404, - "narHash": "sha256-3NJHZv4Ed7haUUmE9JV9Yl4rRnJlPqQFv53Xuw0q+IY=", - "owner": "ErikReider", - "repo": "SwayOSD", - "rev": "a0709bcd89d6ca19889486972bac35e69f1fa8e4", - "type": "github" - }, - "original": { - "owner": "ErikReider", - "repo": "SwayOSD", - "type": "github" - } - }, "systems": { "locked": { "lastModified": 1681028828, @@ -867,36 +759,6 @@ "repo": "default", "type": "github" } - }, - "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_6": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 78f1e0e..2a18484 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ nix-ld-rs = { url = "github:nix-community/nix-ld-rs"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.rust-overlay.follows = "rust-overlay"; + # inputs.rust-overlay.follows = "rust-overlay"; }; qtile = { @@ -50,10 +50,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - swayosd = { - url = "path:flakes/swayosd"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # swayosd = { + # url = "path:flakes/swayosd"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; }; outputs = { @@ -64,7 +64,7 @@ nur, helix, qtile, - swayosd, + # swayosd, nixd, nix-ld-rs, nix-index-database, diff --git a/home/dots/qtile/autostart.sh b/home/dots/qtile/autostart.sh index f557b0d..aa20016 100755 --- a/home/dots/qtile/autostart.sh +++ b/home/dots/qtile/autostart.sh @@ -4,6 +4,7 @@ ckb-next -c -b & mullvad connect & xrdb -l ~/.Xresources & wlr-randr --output HDMI-A-1 --transform 90 +wlr-randr --output DP-1 --pos 1080,450 --adaptive-sync enabled # for later.. # gsettings set org.gnome.desktop.interface gtk-theme '${rice.gtk-theme.name}'";} diff --git a/home/dots/qtile/config.py b/home/dots/qtile/config.py index 654870b..61a5034 100755 --- a/home/dots/qtile/config.py +++ b/home/dots/qtile/config.py @@ -14,6 +14,8 @@ from libqtile.backend import base from libqtile.lazy import lazy from libqtile.config import Key, Match, Screen, Click, Drag, Group, ScratchPad, DropDown, Screen +from lib import centre_float, go_to_group, send_to_next_screen + # from smartfloat import SmartFloat # import qtile_extras.widget as extra_widgets @@ -25,6 +27,7 @@ from libqtile.core.manager import Qtile from libqtile.backend.wayland import InputConfig + wl_input_rules = { "type:keyboard": InputConfig(kb_options="caps:escape"), "*": InputConfig(accel_profile="flat", pointer_accel=0.0), @@ -47,14 +50,22 @@ class Apps: class OSD: mute = "swayosd --output-volume mute-toggle" - vol_up = "swayosd --output-volume raise" - vol_down = "swayosd --output-volume lower" + vol_up = "volumectl -u up" + vol_down = "volumectl -u down" + # vol_up = "pactl set-sink-volume @DEFAULT_SINK@ +5% && notify-send \"Audio Volume\" \"$(pactl get-sink-volume @DEFAULT_SINK@ | cut -d' ' -f 6)\"" + # vol_down = "pactl set-sink-volume @DEFAULT_SINK@ -5% && notify-send \"Audio Volume\" \"$(pactl get-sink-volume @DEFAULT_SINK@ | cut -d' ' -f 6)\"" + # vol_up = "swayosd --output-volume raise" + # vol_down = "swayosd --output-volume lower" next = "playerctl next" prev = "playerctl previous" stop = "playerctl stop" play = "playerctl play-pause" - brightup = "swayosd --brightness raise" - brightdown = "swayosd --brightness lower" + brightup = "lightctl up" + brightdown = "lightctl down" + # brightup = "brightnessctl +5%" + # brightdown = "brightnessctl -5%" + # brightup = "swayosd --brightness raise" + # brightdown = "swayosd --brightness lower" keys = [ @@ -103,44 +114,17 @@ keys = [ Key([mod], "Tab", lazy.next_screen()), ] -def send_to_next_screen() -> Callable: - def _inner(qtile: Qtile) -> None: - win = qtile.current_window - if win is not None: - screen_to_send = (qtile.current_screen.index+1)%2 - win.toscreen(screen_to_send) - qtile.focus_screen(screen_to_send) - if win.floating: - win.bring_to_front() - info = qtile.current_screen.info() - width, height = ((info["width"] // 4) * 3, (info["height"] // 6) * 5) - win.set_size_floating(width, height) - win.center() - return _inner keys.append( Key([mod, "shift"], "Tab", lazy.function(send_to_next_screen())) ) groups = [] -land_groups = "123" -port_groups = "456" -groups.extend([Group(i, screen_affinity=1) for i in land_groups]) -groups.extend([Group(i, screen_affinity=0) for i in port_groups]) - -def go_to_group(name: str) -> Callable: - def _inner(qtile: Qtile) -> None: - if len(qtile.screens) ==1: - qtile.groups_map[name].toscreen() - return - if name in land_groups: - qtile.focus_screen(1) - qtile.groups_map[name].toscreen() - else: - qtile.focus_screen(0) - qtile.groups_map[name].toscreen() - - return _inner +land_groups = "135" +port_groups = "246" +groups.extend([Group(str(i), screen_affinity=(i+1)%2) for i in range(1,7)]) +# groups.extend([Group(i, screen_affinity=1) for i in land_groups]) +# groups.extend([Group(i, screen_affinity=0) for i in port_groups]) for i in groups: keys.extend( @@ -149,7 +133,7 @@ for i in groups: Key( [mod], i.name, - lazy.function(go_to_group(i.name)), + lazy.function(go_to_group(land_groups, port_groups, i.name)), # lazy.group[i.name].toscreen(), desc="Switch to group {}".format(i.name), ), @@ -220,8 +204,8 @@ layout_theme = dict( ) layouts = [ - layout.Bsp(fair=False, border_on_single=True, **layout_theme), - # layout.SmartFloat(**layout_theme), + layout.Bsp(fair=False, margin_on_single=#SINGLE_GAP, border_on_single=True, **layout_theme), + # layout.SmartFloat(**layout_theme), ] widget_defaults = dict( @@ -317,12 +301,7 @@ def centre_floated(): and not win.wants_to_fullscreen and not win.fullscreen ): - win.bring_to_front() - info = qtile.current_screen.info() - width, height = ((info["width"] // 4) * 3, (info["height"] // 6) * 5) - win.set_size_floating(width, height) - win.center() - + qtile.function(centre_float(win, 1.0/6.0*5.0, 1.0/8.0*7.0)) # @hook.subscribe.client_new # def round_and_transparent(client): @@ -332,5 +311,3 @@ def centre_floated(): # logger.warning(client.opacity) # client.rounding = 8 # client.opacity = 0.85 - -qtile.focus_screen(1) diff --git a/home/dots/qtile/lib.py b/home/dots/qtile/lib.py new file mode 100644 index 0000000..3335066 --- /dev/null +++ b/home/dots/qtile/lib.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + + +from __future__ import annotations +from typing import Callable +from libqtile.log_utils import logger +from libqtile.core.manager import Qtile + +def centre_float(win, greater: float, lesser: float) -> Callable: + def _inner(qtile: Qtile) -> None: + win.bring_to_front() + info = qtile.current_screen.info() + width = info["width"] + height = info["height"] + if height > width: + width, height = (width*lesser, height*greater) + else: + width, height = (width*greater, height*lesser) + win.set_size_floating(int(width), int(height)) + win.center() + return _inner + + +def go_to_group(land_groups: str, port_groups: str, name: str) -> Callable: + def _inner(qtile: Qtile) -> None: + if len(qtile.screens) == 1: + qtile.groups_map[name].toscreen() + return + if name in land_groups: + qtile.focus_screen(1) + qtile.groups_map[name].toscreen() + elif name in port_groups: + qtile.focus_screen(0) + qtile.groups_map[name].toscreen() + + return _inner + + +def send_to_next_screen() -> Callable: + def _inner(qtile: Qtile) -> None: + win = qtile.current_window + if win is not None: + screen_to_send = (qtile.current_screen.index+1)%len(qtile.get_screens()) + win.toscreen(screen_to_send) + qtile.focus_screen(screen_to_send) + if ( + win.floating + and not win.maximized + and not win.wants_to_fullscreen + and not win.fullscreen + ): + qtile.function(centre_float(win, 1.0/6.0*5.0, 1.0/8.0*7.0)) + return _inner diff --git a/home/home.nix b/home/home.nix index bcebd92..846cd01 100644 --- a/home/home.nix +++ b/home/home.nix @@ -48,7 +48,6 @@ in { slurp libnotify - swayidle gtklock playerctl @@ -56,7 +55,6 @@ in { xorg.xrdb culr - inputs.swayosd # kdeconnect keepassxc @@ -84,6 +82,35 @@ in { enable = true; }; + services.avizo = { + enable = true; + }; + + services.swayidle = { + enable = true; + timeouts = [ + { + timeout = 300; + command = "${lib.getExe pkgs.gtklock}"; + } + { + timeout = 900; + command = "${lib.getExe' pkgs.systemd "systemctl"} suspend"; + } + ]; + events = [ + { + event = "before-sleep"; + command = "${lib.getExe pkgs.gtklock}"; + } + { + event = "lock"; + command = "${lib.getExe pkgs.gtklock}"; + } + ]; + systemdTarget = "qtile-session.target"; + }; + services.udiskie.enable = false; # TODO change once upstream python package is fixed in nixpkgs programs.vscode = { @@ -114,7 +141,7 @@ in { systemd.user.startServices = "sd-switch"; ezServices = with pkgs; { swaybg = "${lib.getExe swaybg} -i ${rice.bg.image} -m fill"; - swayosd = "${lib.getExe' swayosd "swayosd"} --max-volume 100"; + # swayosd = "${lib.getExe' swayosd "swayosd"} --max-volume 100"; }; xdg.enable = true; diff --git a/home/programs/qtile.nix b/home/programs/qtile.nix index c3bf169..0d68bf6 100644 --- a/home/programs/qtile.nix +++ b/home/programs/qtile.nix @@ -9,6 +9,7 @@ in { config.ezConf = { "qtile/autostart.sh" = ../dots/qtile/autostart.sh; + "qtile/lib.py" = ../dots/qtile/lib.py; }; config.extraTarget = ["qtile-session.target"]; config.xdg.configFile."qtile/config.py" = { @@ -19,6 +20,7 @@ in { with pkgs.rice; (builtins.replaceStrings [ "#GAPS" + "#SINGLE_GAP" "#BORDERWIDTH" "#BORDERFOCUS" "#BORDERCOL" @@ -29,6 +31,7 @@ in { ] [ (builtins.toString borders.gaps_in) + (builtins.toString borders.gaps_out) (builtins.toString borders.thickness) bright.yellow normal.black diff --git a/system/configuration.nix b/system/configuration.nix index 0bfa72a..af2abf4 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -165,6 +165,10 @@ eza swaybg + pulseaudio + pamixer + brightnessctl + git nix-index diff --git a/util/rice.nix b/util/rice.nix index d62c3f0..5a103dd 100644 --- a/util/rice.nix +++ b/util/rice.nix @@ -92,8 +92,8 @@ in rec { borders = { thickness = 6; rounding = 0; - gaps_in = 6; - gaps_out = 6; + gaps_in = 16; + gaps_out = 72; }; bg = {