From 621603d0dad2438aab7cb0bd37e5cbedb4b0efdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Sat, 20 Jun 2026 02:46:58 -0300 Subject: [PATCH] sway: allow setting both internal and external monitors --- pkgs/default.nix | 4 +++ pkgs/lumactl.nix | 54 ++++++++++++++++++++++++++++++++++++++++ pkgs/wmctl.nix | 43 ++++++++++++++++++++++++++++++++ system/greetd.nix | 3 +++ system/users.nix | 1 + user/sway/default.nix | 3 ++- user/sway/sway-binds.nix | 4 +-- 7 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 pkgs/lumactl.nix create mode 100644 pkgs/wmctl.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index f33aa3f..415e419 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,6 +5,10 @@ rec { caffeinated = pkgs.callPackage ./caffeinated { }; cargo-checkmate = pkgs.callPackage ./cargo-checkmate.nix { }; + lumactl = pkgs.callPackage ./lumactl.nix { + wmctl = pkgs.callPackage ./wmctl.nix { }; + }; + wmctl = pkgs.callPackage ./wmctl.nix { }; lipsum = pkgs.callPackage ./lipsum.nix { }; emmet-cli = pkgs.callPackage ./emmet-cli.nix { }; material-wifi-icons = pkgs.callPackage ./material-wifi-icons.nix { }; diff --git a/pkgs/lumactl.nix b/pkgs/lumactl.nix new file mode 100644 index 0000000..cbf2f71 --- /dev/null +++ b/pkgs/lumactl.nix @@ -0,0 +1,54 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + systemd, + libxkbcommon, + wayland, + wayland-scanner, + libffi, + wmctl, + makeWrapper, +}: + +rustPlatform.buildRustPackage rec { + pname = "lumactl"; + version = "0.1.0"; + + src = fetchFromGitHub { + owner = "danyspin97"; + repo = pname; + rev = "89e273e25afe545e3bcaf282b84a63e3c34117de"; + hash = "sha256-PQucBe3xPjjzuiaukdf2f/CvTqbGm0wJMbdpgd2ubnU="; + }; + + cargoHash = "sha256-RvC8wDCY22dBrUcl6VjrwMHwTTSSoBzLwnghAOAUoYU="; + + nativeBuildInputs = [ + pkg-config + wayland-scanner + makeWrapper + ]; + buildInputs = [ + systemd + libxkbcommon + wayland + libffi + wmctl + ]; + + postFixup = '' + wrapProgram $out/bin/lumactl \ + --prefix PATH : ${lib.makeBinPath [ wmctl ]} + ''; + + meta = with lib; { + description = "CLI utility for controlling display brightness on Linux"; + homepage = "https://github.com/danyspin97/lumactl"; + license = licenses.gpl3Plus; + mainProgram = "lumactl"; + platforms = platforms.linux; + maintainers = with maintainers; [ lelgenio ]; + }; +} diff --git a/pkgs/wmctl.nix b/pkgs/wmctl.nix new file mode 100644 index 0000000..7be8e92 --- /dev/null +++ b/pkgs/wmctl.nix @@ -0,0 +1,43 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + libxkbcommon, + wayland, + wayland-scanner, + libffi, +}: + +rustPlatform.buildRustPackage rec { + pname = "wmctl"; + version = "0.1.0"; + + src = fetchFromGitHub { + owner = "danyspin97"; + repo = pname; + rev = "398d87945ab6c4b31e04063098c79d1e456afdcc"; + hash = "sha256-J3ZHq51uDgPMcQbJzEflReDnm1AqPs7Hov3jpCDlNHU="; + }; + + cargoHash = "sha256-T7FdevuBLbrYE5vTuBincSRMDOLkUsoKx/jg0i1Ybdo="; + + nativeBuildInputs = [ + pkg-config + wayland-scanner + ]; + buildInputs = [ + libxkbcommon + wayland + libffi + ]; + + meta = with lib; { + description = "CLI for controlling Wayland compositors"; + homepage = "https://github.com/danyspin97/wmctl"; + license = licenses.gpl3Plus; + mainProgram = "wmctl"; + platforms = platforms.linux; + maintainers = with maintainers; [ lelgenio ]; + }; +} diff --git a/system/greetd.nix b/system/greetd.nix index 8642968..606d518 100644 --- a/system/greetd.nix +++ b/system/greetd.nix @@ -25,6 +25,9 @@ in # Enable the X11 windowing system. services.xserver.enable = false; + # Enable external monitor configuration (brightness) + hardware.i2c.enable = true; + # enable sway window manager programs.sway = { enable = true; diff --git a/system/users.nix b/system/users.nix index c1a1039..1e3c93c 100644 --- a/system/users.nix +++ b/system/users.nix @@ -22,6 +22,7 @@ "input" "libvirtd" "kvm" + "i2c" ]; shell = pkgs.fish; openssh.authorizedKeys.keys = [ diff --git a/user/sway/default.nix b/user/sway/default.nix index 9a0c791..2921be5 100644 --- a/user/sway/default.nix +++ b/user/sway/default.nix @@ -155,7 +155,8 @@ in wdmenu wlauncher volumesh - brightnessctl + wmctl + lumactl showkeys pamixer libnotify diff --git a/user/sway/sway-binds.nix b/user/sway/sway-binds.nix index a68a31b..925e346 100644 --- a/user/sway/sway-binds.nix +++ b/user/sway/sway-binds.nix @@ -160,8 +160,8 @@ let }; screen_binds = { - "XF86MonBrightnessDown" = "exec brightnessctl --min-value=1 set 5%-"; - "XF86MonBrightnessUp" = "exec brightnessctl --min-value=1 set 5%+"; + "XF86MonBrightnessDown" = "exec lumactl set -- -5%"; + "XF86MonBrightnessUp" = "exec lumactl set -- +5%"; "${mod}+l" = "exec ${lib.getExe _lock}"; };