Add power_profiles prompt to framework

This commit is contained in:
Natsu Kagami 2024-08-02 18:12:11 +02:00
parent 28080d31c0
commit 45e90570b7
Signed by: nki
GPG key ID: 55A032EB38B49ADB
4 changed files with 26 additions and 12 deletions

View file

@ -57,7 +57,6 @@ in
feh # For images? feh # For images?
deluge # Torrent client deluge # Torrent client
pavucontrol # PulseAudio control panel pavucontrol # PulseAudio control panel
cinnamon.nemo # File manager
thunderbird # Email thunderbird # Email
sublime-music # For navidrome sublime-music # For navidrome
cinny-desktop cinny-desktop

View file

@ -14,7 +14,7 @@ let
systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "sway-session.target" ]; systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "sway-session.target" ];
programs.my-sway.waybar = { programs.my-sway.waybar = {
extraSettings = { extraSettings = [{
modules-right = mkAfter [ "custom/swaync" ]; modules-right = mkAfter [ "custom/swaync" ];
modules."custom/swaync" = { modules."custom/swaync" = {
tooltip = false; tooltip = false;
@ -36,7 +36,7 @@ let
on-click-right = "${swaync}/bin/swaync-client -d -sw"; on-click-right = "${swaync}/bin/swaync-client -d -sw";
escape = true; escape = true;
}; };
}; }];
extraStyle = mkAfter '' extraStyle = mkAfter ''
#custom-swaync { #custom-swaync {
background: #F0FFFF; background: #F0FFFF;

View file

@ -110,12 +110,12 @@ in
default = barWith: [ (barWith { }) ]; default = barWith: [ (barWith { }) ];
}; };
extraSettings = mkOption { extraSettings = mkOption {
type = types.raw; type = types.listOf types.raw;
description = "Extra settings to be included with every default bar"; description = "Extra settings to be included with every default bar";
default = { }; default = [ ];
}; };
extraStyle = mkOption { extraStyle = mkOption {
type = types.str; type = types.lines;
description = "Additional style for the default waybar"; description = "Additional style for the default waybar";
default = ""; default = "";
}; };
@ -409,7 +409,7 @@ in
config.programs.waybar = config.programs.waybar =
let let
barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: (mkMerge [{ barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: mkMerge ([{
position = "top"; position = "top";
modules-left = [ modules-left = [
"sway/workspaces" "sway/workspaces"
@ -420,7 +420,7 @@ in
]; ];
modules-right = modules-right =
lib.optional showMedia (if cfg.enableMpd then "mpd" else "custom/media") lib.optional showMedia (if cfg.enableMpd then "mpd" else "custom/media")
++ [ ++ [
"tray" "tray"
"pulseaudio" "pulseaudio"
] ++ lib.optionals showConnectivity [ ] ++ lib.optionals showConnectivity [
@ -431,7 +431,7 @@ in
"memory" "memory"
"temperature" "temperature"
] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ] ] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ]
++ [ ++ [
"clock" "clock"
]; ];
@ -598,9 +598,9 @@ in
"on-click" = "${playerctl} play-pause"; "on-click" = "${playerctl} play-pause";
}; };
}; };
} }] ++
cfg.waybar.extraSettings cfg.waybar.extraSettings
extraSettings]); ++ [ extraSettings ]);
in in
mkIf cfg.enable { mkIf cfg.enable {
enable = true; enable = true;

View file

@ -48,6 +48,21 @@
tap = "enabled"; 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 # input-remapping
xdg.configFile."autostart/input-remapper-autoload.desktop".source = xdg.configFile."autostart/input-remapper-autoload.desktop".source =