From 45e90570b75c47cdf17f02a44ef77955e7085b0e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 2 Aug 2024 18:12:11 +0200 Subject: [PATCH] Add power_profiles prompt to framework --- home/modules/linux/graphical/default.nix | 1 - home/modules/linux/graphical/wayland.nix | 4 ++-- home/modules/programs/my-sway/default.nix | 18 +++++++++--------- home/nki-framework.nix | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index dc1ad15..186ccd7 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -57,7 +57,6 @@ in feh # For images? deluge # Torrent client pavucontrol # PulseAudio control panel - cinnamon.nemo # File manager thunderbird # Email sublime-music # For navidrome cinny-desktop diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index 7073057..a403195 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -14,7 +14,7 @@ let systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "sway-session.target" ]; programs.my-sway.waybar = { - extraSettings = { + extraSettings = [{ modules-right = mkAfter [ "custom/swaync" ]; modules."custom/swaync" = { tooltip = false; @@ -36,7 +36,7 @@ let on-click-right = "${swaync}/bin/swaync-client -d -sw"; escape = true; }; - }; + }]; extraStyle = mkAfter '' #custom-swaync { background: #F0FFFF; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index ed10524..7c6052f 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -110,12 +110,12 @@ in default = barWith: [ (barWith { }) ]; }; extraSettings = mkOption { - type = types.raw; + type = types.listOf types.raw; description = "Extra settings to be included with every default bar"; - default = { }; + default = [ ]; }; extraStyle = mkOption { - type = types.str; + type = types.lines; description = "Additional style for the default waybar"; default = ""; }; @@ -409,7 +409,7 @@ in config.programs.waybar = let - barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: (mkMerge [{ + barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: mkMerge ([{ position = "top"; modules-left = [ "sway/workspaces" @@ -420,7 +420,7 @@ in ]; modules-right = lib.optional showMedia (if cfg.enableMpd then "mpd" else "custom/media") - ++ [ + ++ [ "tray" "pulseaudio" ] ++ lib.optionals showConnectivity [ @@ -431,7 +431,7 @@ in "memory" "temperature" ] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ] - ++ [ + ++ [ "clock" ]; @@ -598,9 +598,9 @@ in "on-click" = "${playerctl} play-pause"; }; }; - } - cfg.waybar.extraSettings - extraSettings]); + }] ++ + cfg.waybar.extraSettings + ++ [ extraSettings ]); in mkIf cfg.enable { enable = true; diff --git a/home/nki-framework.nix b/home/nki-framework.nix index 097a175..88509eb 100644 --- a/home/nki-framework.nix +++ b/home/nki-framework.nix @@ -48,6 +48,21 @@ tap = "enabled"; }; }; + programs.my-sway.waybar.extraSettings = + let + change-mode = pkgs.writeScript "change-mode" '' + #!/usr/bin/env ${lib.getExe pkgs.fish} + set -ax PATH ${lib.getBin pkgs.power-profiles-daemon} ${lib.getBin pkgs.rofi} ${lib.getBin pkgs.ripgrep} + + set profiles (powerprofilesctl list | rg "^[ *] (\S+):" -r '$1') + set selected_index (math (contains -i (powerprofilesctl get) $profiles) - 1) + set new_profile (printf "%s\n" $profiles | rofi -dmenu -p "Switch to power profile" -a $selected_index) + powerprofilesctl set $new_profile + ''; + in + [{ + modules."battery"."on-click" = change-mode; + }]; # input-remapping xdg.configFile."autostart/input-remapper-autoload.desktop".source =