From 3ae8931afbeed5d80d87b7c02d0fe5548134c7bb Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 23 Sep 2023 17:22:40 +0200 Subject: [PATCH] feat: add autorandr for automatically switching monitor layout --- modules/desktop/qtile/config/config.py | 4 +- modules/desktop/qtile/home.nix | 69 ++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/modules/desktop/qtile/config/config.py b/modules/desktop/qtile/config/config.py index eaf384a..7bb78a1 100644 --- a/modules/desktop/qtile/config/config.py +++ b/modules/desktop/qtile/config/config.py @@ -328,13 +328,13 @@ def create_bottom_bar(): ), ], 30) -def init_screen(top_bar, wallpaper, index): +def init_screen(top_bar, wallpaper): return Screen(top=top_bar, bottom=create_bottom_bar(), wallpaper=wallpaper, width=1920, height=1080) screens = [ - init_screen(create_top_bar(), f'{setupLocation}/wall.png'), init_screen(create_top_bar(systray = True), f'{setupLocation}/wall.png'), init_screen(create_top_bar(), f'{setupLocation}/wall.png'), + init_screen(create_top_bar(), f'{setupLocation}/wall.png'), ] # Keys diff --git a/modules/desktop/qtile/home.nix b/modules/desktop/qtile/home.nix index 73e04b3..62d5a50 100644 --- a/modules/desktop/qtile/home.nix +++ b/modules/desktop/qtile/home.nix @@ -1,6 +1,75 @@ { config, lib, pkgs, location, ... }: { + # services.udev.extraRules = + # ''ACTION=="change", SUBSYSTEM=="drm", RUN+="${pkgs.autorandr}/bin/autorandr -c"''; + programs.autorandr = { + enable = true; + hooks = { + postswitch = { + "reload-qtile" = "${pkgs.qtile}/bin/qtile cmd-obj -o cmd -f reload_config"; + }; + }; + profiles = { + "desktop" = { + fingerprint = { + DVI-D-0 = "00ffffffffffff0009d1d978455400002b1a010380351e782e6c40a755519f27145054a56b80d1c081c081008180a9c0b30001010101023a801871382d40582c45000f282100001e000000ff0054414730333931303031390a20000000fd00324c1e5311000a202020202020000000fc0042656e51204757323437300a200161020322f14f901f05140413031207161501061102230907078301000065030c002000023a801871382d40582c45000f282100001e011d8018711c1620582c25000f282100009e011d007251d01e206e2855000f282100001e8c0ad08a20e02d10103e96000f2821000018000000000000000000000000000000000000000000f5"; + DisplayPort-0 = "00ffffffffffff0009d1e77801010101261e0104a5351e783a05f5a557529c270b5054a56b80d1c0b300a9c08180810081c001010101023a801871382d40582c45000f282100001e000000ff00455442394c3033373432534c30000000fd00324c1e5311010a202020202020000000fc0042656e51204757323438300a2001e002031cf14f901f041303120211011406071516052309070783010000023a801871382d40582c45000f282100001f011d8018711c1620582c25000f282100009f011d007251d01e206e2855000f282100001e8c0ad08a20e02d10103e96000f28210000180000000000000000000000000000000000000000000000000000008d"; + HDMI-A-0 = "00ffffffffffff0009d1e778455400000d1c010380351e782e0565a756529c270f5054a56b80d1c0b300a9c08180810081c001010101023a801871382d40582c45000f282100001e000000ff0058334a30303131303031510a20000000fd00324c1e5311000a202020202020000000fc0042656e51204757323438300a2001b0020322f14f901f04130312021101140607151605230907078301000065030c001000023a801871382d40582c45000f282100001f011d8018711c1620582c25000f282100009f011d007251d01e206e2855000f282100001e8c0ad08a20e02d10103e96000f282100001800000000000000000000000000000000000000000003"; + }; + config = { + DVI-D-0 = { + enable = true; + crtc = 0; + primary = false; + position = "0x0"; + mode = "1920x1080"; + gamma = "1.0:0.909:0.833"; + rate = "60.00"; + }; + DisplayPort-0 = { + enable = true; + crtc = 0; + primary = true; + position = "1920x0"; + mode = "1920x1080"; + gamma = "1.0:0.909:0.833"; + rate = "60.00"; + }; + HDMI-A-0 = { + enable = true; + crtc = 0; + primary = true; + position = "3840x0"; + mode = "1920x1080"; + gamma = "1.0:0.909:0.833"; + rate = "60.00"; + }; + }; + }; + "virtual" = { + fingerprint = { + Virtual-1 = "00ffffffffffff0049143412000000002a180104a530197806ee91a3544c99260f5054210800e1c0d1c0d100a940b3009500818081405a4f80a072f22330e0395540e70011000018000000f7000a004082002820000000000000000000fd00327d1ea0ff010a202020202020000000fc0051454d55204d6f6e69746f720a019902030b00467d6560591f6100000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000000000000002f"; + Virtual-2 = "00ffffffffffff0049143412000000002a180104a5301b7806ee91a3544c99260f5054210800e1c0d1c0d100a940b300950081808140d25480a072382540e0395540e71211000018000000f7000a004082002820000000000000000000fd00327d1ea0ff010a202020202020000000fc0051454d55204d6f6e69746f720a01b002030b00467d6560591f6100000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000010000000000000000000000000000000000000000000002f"; + }; + config = { + Virtual-1 = { + enable = true; + primary = true; + position = "0x0"; + mode = "1920x1080"; + }; + Virtual-2= { + enable = true; + primary = false; + position = "1920x0"; + mode = "1920x1080"; + }; + }; + }; + }; + }; + xdg.configFile."qtile/config.py".source = ./config/config.py; xdg.configFile."qtile/bluetooth.py".source = ./config/bluetooth.py; xdg.configFile."qtile/mpris2widget.py".source = ./config/mpris2widget.py; -- 2.48.1