rewrite home modules to dynamically get executables iwth lib.getExe and lib.getExe'

This commit is contained in:
Aly Raffauf 2024-05-05 19:39:36 -04:00
parent 9625af21f5
commit 5634e4e8a3
8 changed files with 147 additions and 83 deletions

View file

@ -23,8 +23,8 @@
"files.autoSave" = "afterDelay";
"git.autofetch" = true;
"git.confirmSync" = false;
"nix.formatterPath" = "${pkgs.alejandra}/bin/alejandra";
"terminal.external.linuxExec" = "${pkgs.alacritty}/bin/alacritty";
"nix.formatterPath" = lib.getExe pkgs.alejandra;
"terminal.external.linuxExec" = lib.getExe pkgs.alacritty;
"update.mode" = "none";
"window.menuBarVisibility" = "hidden";
"window.zoomPerWindow" = false;

View file

@ -128,7 +128,7 @@
"sort-by" = "id";
};
"hyprland/submap" = {
"on-click" = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch submap reset";
"on-click" = ''${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch submap reset'';
};
"hyprland/window" = {
"format" = "";
@ -146,7 +146,7 @@
"sort-by" = "id";
};
"sway/mode" = {
"on-click" = "${config.wayland.windowManager.sway.package}/bin/swaymsg mode default";
"on-click" = ''${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} mode default'';
};
"sway/window" = {
"max-length" = 100;
@ -188,7 +188,7 @@
{device_enumerate}'';
"tooltip-format-enumerate-connected" = "{device_alias} {device_address}";
"on-click" = "${pkgs.blueberry}/bin/blueberry";
"on-click" = lib.getExe' pkgs.blueberry "blueberry";
};
"pulseaudio" = {
"format" = "{icon}";
@ -202,7 +202,7 @@
};
"scroll-step" = 5;
"ignored-sinks" = ["Easy Effects Sink"];
"on-click" = "${pkgs.pavucontrol}/bin/pavucontrol -t 3";
"on-click" = "${lib.getExe pkgs.pavucontrol} -t 3";
};
"network" = {
"format-wifi" = "{icon}";
@ -213,11 +213,11 @@
"tooltip-format-wifi" = "{essid} ({signalStrength}%) {icon}";
"tooltip-format-ethernet" = "{ifname} ";
"tooltip-format-disconnected" = "Disconnected";
"on-click" = "${pkgs.alacritty}/bin/alacritty --class nmtui -e ${pkgs.networkmanager}/bin/nmtui";
"on-click" = "${lib.getExe pkgs.alacritty} --class nmtui -e ${pkgs.networkmanager}/bin/nmtui";
};
"tray" = {"spacing" = 15;};
"custom/logout" = {
"on-click" = "${pkgs.wlogout}/bin/wlogout";
"on-click" = "${lib.getExe pkgs.wlogout}";
"format" = "󰗽";
};
"power-profiles-daemon" = {

View file

@ -12,19 +12,19 @@
layout = [
{
label = "logout";
action = "${pkgs.systemd}/bin/loginctl terminate-user ${config.home.username}";
action = ''${lib.getExe' pkgs.systemd "loginctl"} terminate-user ${config.home.username}'';
text = "Logout";
keybind = "e";
}
{
label = "shutdown";
action = "${pkgs.systemd}/bin/systemctl poweroff";
action = ''${lib.getExe' pkgs.systemd "systemctl"} poweroff'';
text = "Shutdown";
keybind = "s";
}
{
label = "reboot";
action = "${pkgs.systemd}/bin/systemctl reboot";
action = ''${lib.getExe' pkgs.systemd "systemctl"} reboot'';
text = "Reboot";
keybind = "r";
}

View file

@ -0,0 +1,64 @@
{
pkgs,
lib,
config,
...
}: {
options = {
alyraffauf.desktop.defaultApps.enable =
lib.mkEnableOption "GTK and Qt themes.";
alyraffauf.desktop.defaultApps.browser = {
name = lib.mkOption {
description = "Default web browser executable name.";
default = "firefox";
type = lib.types.str;
};
desktop = lib.mkOption {
description = "Default web browser desktop file name.";
default = "firefox.desktop";
type = lib.types.str;
};
package = lib.mkOption {
description = "Default web browser package.";
default = pkgs.firefox;
type = lib.types.package;
};
};
alyraffauf.desktop.defaultApps.editor = {
name = lib.mkOption {
description = "Default editor executable name.";
default = "codium";
type = lib.types.str;
};
desktop = lib.mkOption {
description = "Default editor desktop file name.";
default = "codium.desktop";
type = lib.types.str;
};
package = lib.mkOption {
description = "Default editor package.";
default = pkgs.vsCodium;
type = lib.types.package;
};
};
};
config = lib.mkIf config.alyraffauf.desktop.theme.enable {
xdg.mimeApps = {
enable = true;
defaultApplications = {
"application/xhtml+xml" = "firefox.desktop";
"text/html" = "firefox.desktop";
"text/xml" = "firefox.desktop";
"x-scheme-handler/ftp" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
};
};
home.sessionVariables = {
EDITOR = "${lib.getExe pkgs.neovim}";
BROWSER = "${lib.getExe pkgs.firefox}";
TERMINAL = "${lib.getExe pkgs.kitty}";
};
};
}

View file

@ -63,13 +63,13 @@
modifier = "SUPER";
# Default apps
browser = pkgs.firefox + "/bin/firefox";
fileManager = pkgs.xfce.thunar + "/bin/thunar";
editor = pkgs.vscodium + "/bin/codium";
terminal = pkgs.alacritty + "/bin/alacritty";
browser = lib.getExe pkgs.firefox;
fileManager = lib.getExe pkgs.xfce.thunar;
editor = lib.getExe pkgs.vscodium;
terminal = lib.getExe pkgs.alacritty;
# Media/hardware commands
# brightness = "${pkgs.brightnessctl}/bin/brightnessctl";
# brightness = "${lib.getExe pkgs.brightnessctl}";
# brightness_up = "${brightness} set 5%+";
# brightness_down = "${brightness} set 5%-";
# volume = "${pkgs.wireplumber}/bin/wpctl";
@ -77,44 +77,44 @@
# volume_down = "${volume} set-volume -l 1.0 @DEFAULT_SINK@ 5%-";
# volume_mute = "${volume} set-mute @DEFAULT_SINK@ toggle";
# mic_mute = "${volume} set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
brightness = "${pkgs.swayosd}/bin/swayosd-client";
brightness = lib.getExe' pkgs.swayosd "swayosd-client";
brightness_up = "${brightness} --brightness=raise";
brightness_down = "${brightness} --brightness=lower";
volume = "${pkgs.swayosd}/bin/swayosd-client";
volume = brightness;
volume_up = "${volume} --output-volume=raise";
volume_down = "${volume} --output-volume=lower";
volume_mute = "${volume} --output-volume=mute-toggle";
mic_mute = "${volume} --input-volume=mute-toggle";
media = "${pkgs.playerctl}/bin/playerctl";
media = lib.getExe pkgs.playerctl;
media_play = "${media} play-pause";
media_next = "${media} next";
media_prev = "${media} previous";
# Hyprland desktop utilities
bar = pkgs.waybar + "/bin/waybar";
launcher = pkgs.fuzzel + "/bin/fuzzel";
notifyd = pkgs.mako + "/bin/mako";
wallpaperd = pkgs.hyprpaper + "/bin/hyprpaper";
logout = pkgs.wlogout + "/bin/wlogout";
bar = lib.getExe pkgs.waybar;
launcher = lib.getExe pkgs.fuzzel;
notifyd = lib.getExe pkgs.mako;
wallpaperd = lib.getExe pkgs.hyprpaper;
logout = lib.getExe pkgs.wlogout;
# lock = pkgs.hyprlock + "/bin/hyprlock --immediate";
# idled = pkgs.hypridle + "/bin/hypridle";
lock = pkgs.swaylock + ''/bin/swaylock'';
lock = lib.getExe pkgs.swaylock;
idled =
if config.alyraffauf.desktop.hyprland.autoSuspend
then ''
${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on' timeout 900 '${pkgs.systemd}/bin/systemctl suspend' before-sleep '${media} pause' before-sleep '${lock}'
${lib.getExe pkgs.swayidle} -w timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r' timeout 300 '${lock}' timeout 330 '${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms off' resume '${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms on' timeout 900 '${lib.getExe' pkgs.systemd "systemctl"}' before-sleep '${media} pause' before-sleep '${lock}'
''
else ''
${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on' before-sleep '${media} pause' before-sleep '${lock}'
${lib.getExe pkgs.swayidle} -w timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r' timeout 300 '${lock}' timeout 330 '${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms off' resume '${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch dpms on' before-sleep '${media} pause' before-sleep '${lock}'
'';
hyprnome = pkgs.hyprnome + "/bin/hyprnome";
hyprshade = pkgs.hyprshade + "/bin/hyprshade";
hyprnome = lib.getExe pkgs.hyprnome;
hyprshade = lib.getExe pkgs.hyprshade;
screenshot = "${pkgs.hyprshot}/bin/hyprshot";
screenshot = lib.getExe pkgs.hyprshot;
screenshot_folder = "~/pics/screenshots";
screenshot_screen = "${screenshot} -m output -o ${screenshot_folder}";
screenshot_region = "${screenshot} -m region -o ${screenshot_folder}";
@ -153,15 +153,15 @@
exec-once = ${wallpaperd}
exec-once = ${bar}
exec-once = ${notifyd}
exec-once = ${pkgs.wl-clipboard}/bin/wl-paste --type text --watch cliphist store
exec-once = ${pkgs.wl-clipboard}/bin/wl-paste --type image --watch cliphist store
exec-once = ${lib.getExe' pkgs.wl-clipboard "wl-paste"} --type image --watch ${lib.getExe pkgs.cliphist} store
exec-once = ${lib.getExe' pkgs.wl-clipboard "wl-paste"} --type text --watch ${lib.getExe pkgs.cliphist} store
exec-once = ${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1
exec-once = ${fileManager} --daemon
exec = ${pkgs.hyprshade}/bin/hyprshade auto
exec = ${hyprshade} auto
exec-once = ${idled}
exec-once = ${pkgs.swayosd}/bin/swayosd-server
exec-once = ${pkgs.networkmanagerapplet}/bin/nm-applet
exec-once = ${pkgs.playerctl}/bin/playerctld
exec-once = ${lib.getExe' pkgs.swayosd "swayosd-server"}
exec-once = ${lib.getExe' pkgs.networkmanagerapplet "nm-applet"}
exec-once = ${lib.getExe' pkgs.playerctl "playerctld"}
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {

View file

@ -49,56 +49,56 @@
modifier = "Mod4";
# Default apps
browser = pkgs.firefox + "/bin/firefox";
fileManager = pkgs.xfce.thunar + "/bin/thunar";
editor = pkgs.vscodium + "/bin/codium";
terminal = pkgs.alacritty + "/bin/alacritty";
browser = lib.getExe pkgs.firefox;
fileManager = lib.getExe pkgs.xfce.thunar;
editor = lib.getExe pkgs.vscodium;
terminal = lib.getExe pkgs.alacritty;
brightness = "${pkgs.swayosd}/bin/swayosd-client";
brightness = lib.getExe' pkgs.swayosd "swayosd-client";
brightness_up = "${brightness} --brightness=raise";
brightness_down = "${brightness} --brightness=lower";
volume = "${pkgs.swayosd}/bin/swayosd-client";
volume = brightness;
volume_up = "${volume} --output-volume=raise";
volume_down = "${volume} --output-volume=lower";
volume_mute = "${volume} --output-volume=mute-toggle";
mic_mute = "${volume} --input-volume=mute-toggle";
media = "${pkgs.playerctl}/bin/playerctl";
media = lib.getExe pkgs.playerctl;
media_play = "${media} play-pause";
media_next = "${media} next";
media_prev = "${media} previous";
# Sway desktop utilities
bar = pkgs.waybar + "/bin/waybar";
launcher = pkgs.fuzzel + "/bin/fuzzel";
notifyd = pkgs.mako + "/bin/mako";
wallpaperd = pkgs.swaybg + "/bin/swaybg -i ${config.alyraffauf.desktop.theme.wallpaper}";
logout = pkgs.wlogout + "/bin/wlogout";
lock = pkgs.swaylock + ''/bin/swaylock'';
bar = lib.getExe pkgs.waybar;
launcher = lib.getExe pkgs.fuzzel;
notifyd = lib.getExe pkgs.mako;
wallpaperd = lib.getExe pkgs.swaybg;
logout = lib.getExe pkgs.wlogout;
lock = lib.getExe pkgs.swaylock;
idled =
if config.alyraffauf.desktop.sway.autoSuspend
then ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' \
resume '${pkgs.brightnessctl}/bin/brightnessctl -r' \
${lib.getExe pkgs.swayidle} -w \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${lock}' \
timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \
resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \
timeout 900 '${pkgs.systemd}/bin/systemctl suspend' \
timeout 330 '${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} "output * dpms off"' \
resume '${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} "output * dpms on"' \
timeout 900 '${lib.getExe' pkgs.systemd "systemctl"} suspend' \
before-sleep '${media} pause' \
before-sleep '${lock}'
''
else ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' \
resume '${pkgs.brightnessctl}/bin/brightnessctl -r' \
${lib.getExe pkgs.swayidle} -w \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${lock}' \
timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \
resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \
timeout 330 '${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} "output * dpms off"' \
resume '${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} "output * dpms on"' \
before-sleep '${media} pause' \
before-sleep '${lock}'
'';
screenshot = "${pkgs.shotman}/bin/shotman";
screenshot = lib.getExe' pkgs.shotman "shotman";
# screenshot_folder = "~/pics/screenshots";
# screenshot_screen = "${screenshot} ${screenshot_folder}/$(date +'%s_grim.png')";
# screenshot_region = "${screenshot} -m region -o ${screenshot_folder}";
@ -110,14 +110,14 @@
cycleSwayDisplayModes = pkgs.writeShellScriptBin "cycleSwayDisplayModes" ''
# TODO: remove petalburg hardcodes
current_mode=$(${config.wayland.windowManager.sway.package}/bin/swaymsg -t get_outputs -p | grep "Current mode" | grep -Eo '[0-9]+x[0-9]+ @ [0-9.]+ Hz' | tr -d " " | grep 2880)
current_mode=$(${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} -t get_outputs -p | grep "Current mode" | grep -Eo '[0-9]+x[0-9]+ @ [0-9.]+ Hz' | tr -d " " | grep 2880)
if [ $current_mode = "2880x1800@90.001Hz" ]; then
${config.wayland.windowManager.sway.package}/bin/swaymsg output "eDP-1" mode "2880x1800@60.001Hz";
${pkgs.libnotify}/bin/notify-send "Display set to 2880x1800@60.001Hz."
${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} output "eDP-1" mode "2880x1800@60.001Hz";
${lib.getExe pkgs.libnotify} "Display set to 2880x1800@60.001Hz."
elif [ $current_mode = "2880x1800@60.001Hz" ]; then
${config.wayland.windowManager.sway.package}/bin/swaymsg output "eDP-1" mode "2880x1800@90.001Hz";
${pkgs.libnotify}/bin/notify-send "Display set to 2880x1800@90.001Hz."
${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} output "eDP-1" mode "2880x1800@90.001Hz";
${lib.getExe pkgs.libnotify} "Display set to 2880x1800@90.001Hz."
fi
'';
in {
@ -277,7 +277,7 @@
# For petalburg
"XF86Launch4" = "exec pp-adjuster";
"XF86Launch3" = "exec ${cycleSwayDisplayModes}/bin/cycleSwayDisplayModes";
"XF86Launch3" = "exec ${lib.getExe cycleSwayDisplayModes}";
# TODO: night color shift
# "XF86Launch1" =
@ -332,14 +332,14 @@
{command = "${fileManager} --daemon";}
{command = "${idled}";}
{command = "${notifyd}";}
{command = "${pkgs.autotiling}/bin/autotiling";}
{command = "${pkgs.gammastep}/bin/gammastep -l 31.1:-94.1";} # TODO: automatic locations
{command = "${lib.getExe pkgs.autotiling}";}
{command = "${lib.getExe pkgs.gammastep} -l 31.1:-94.1";} # TODO: automatic locations
{command = "${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1";}
{command = "${pkgs.networkmanagerapplet}/bin/nm-applet";}
{command = "${pkgs.swayosd}/bin/swayosd-server";}
{command = "${pkgs.playerctl}/bin/playerctld";}
{command = "${pkgs.wl-clipboard}/bin/wl-paste --type image --watch ${pkgs.cliphist}/bin/cliphist store";}
{command = "${pkgs.wl-clipboard}/bin/wl-paste --type text --watch ${pkgs.cliphist}/bin/cliphist store";}
{command = ''${lib.getExe' pkgs.networkmanagerapplet "nm-applet"}'';}
{command = ''${lib.getExe' pkgs.swayosd "swayosd-server"}'';}
{command = ''${lib.getExe' pkgs.playerctl "playerctld"}'';}
{command = ''${lib.getExe' pkgs.wl-clipboard "wl-paste"} --type image --watch ${lib.getExe pkgs.cliphist} store'';}
{command = ''${lib.getExe' pkgs.wl-clipboard "wl-paste"} --type text --watch ${lib.getExe pkgs.cliphist} store'';}
];
output = {
"BOE 0x095F Unknown" = {

View file

@ -14,10 +14,10 @@
while true; do
NEW_PIDS=()
monitor=`${config.wayland.windowManager.sway.package}/bin/swaymsg -t get_outputs -p | grep Output | awk '{print $2}'`
monitor=`${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} -t get_outputs -p | grep Output | awk '{print $2}'`
for m in ''${monitor[@]}; do
random_background=$(ls $directory/*.{png,jpg} | shuf -n 1)
${pkgs.swaybg}/bin/swaybg -o $m -i $random_background &
${lib.getExe pkgs.swaybg} -o $m -i $random_background &
NEW_PIDS+=($!)
done
@ -44,7 +44,7 @@ in {
home.packages = with pkgs; [swaybg sway-randomWallpaper];
wayland.windowManager.sway.config.startup = [
{command = "${sway-randomWallpaper}/bin/sway-randomWallpaper";}
{command = "${lib.getExe sway-randomWallpaper}";}
];
};
}

View file

@ -6,18 +6,18 @@
}: let
pp-adjuster = pkgs.writeShellScriptBin "pp-adjuster" ''
# Only works on petalburg.
current_profile=$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get | tr -d '[:space:]')
current_profile=$(${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} get | tr -d '[:space:]')
if [ "$current_profile" == "power-saver" ]; then
${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced
${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} set balanced
elif [ "$current_profile" == "balanced" ]; then
${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance
${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} set performance
elif [ "$current_profile" == "performance" ]; then
${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver
${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} set power-saver
fi
new_profile=$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get | tr -d '[:space:]')
${pkgs.libnotify}/bin/notify-send "Power profile set to $new_profile."
new_profile=$(${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} get | tr -d '[:space:]')
${lib.getExe pkgs.libnotify} "Power profile set to $new_profile."
'';
in {
options = {alyraffauf.scripts.pp-adjuster.enable = lib.mkEnableOption "Enable pp-adjuster script.";};