sway: refer to fewer programs in the config by absolute path

this aids in sandboxing and swapping stuff in/out at runtime
This commit is contained in:
Colin 2024-02-05 23:38:43 +00:00
parent 1c4e2f97fe
commit 3f96f4af82
2 changed files with 45 additions and 35 deletions

View File

@ -25,7 +25,7 @@ let
''; '';
in pkgs.symlinkJoin { in pkgs.symlinkJoin {
inherit (configuredSway) name meta; inherit (configuredSway) name meta;
# the order of these `paths` is suchs that the desktop-file should claim share/wayland-sessions/sway.deskop, # the order of these `paths` is such that the desktop-file should claim share/wayland-sessions/sway.deskop,
# overriding whatever the configuredSway provides # overriding whatever the configuredSway provides
paths = [ desktop-file configuredSway ]; paths = [ desktop-file configuredSway ];
passthru = { passthru = {
@ -42,7 +42,7 @@ let
withBaseWrapper = config.programs.sway.wrapperFeatures.base; withBaseWrapper = config.programs.sway.wrapperFeatures.base;
withGtkWrapper = config.programs.sway.wrapperFeatures.gtk; withGtkWrapper = config.programs.sway.wrapperFeatures.gtk;
isNixOS = true; isNixOS = true;
# TODO: `enableXWayland = ...`? # TODO: `enableXWayland = ...`?
}; };
in in
{ {
@ -118,17 +118,17 @@ in
# TODO: split these into their own option scope # TODO: split these into their own option scope
brightness_down_cmd = mkOption { brightness_down_cmd = mkOption {
type = types.str; type = types.str;
default = "${pkgs.brightnessctl}/bin/brightnessctl set 2%-"; default = "brightnessctl set 2%-";
description = "command to run when use wants to decrease screen brightness"; description = "command to run when use wants to decrease screen brightness";
}; };
brightness_up_cmd = mkOption { brightness_up_cmd = mkOption {
type = types.str; type = types.str;
default = "${pkgs.brightnessctl}/bin/brightnessctl set +2%"; default = "brightnessctl set +2%";
description = "command to run when use wants to increase screen brightness"; description = "command to run when use wants to increase screen brightness";
}; };
screenshot_cmd = mkOption { screenshot_cmd = mkOption {
type = types.str; type = types.str;
default = "${pkgs.sway-contrib.grimshot}/bin/grimshot copy area"; default = "grimshot copy area";
description = "command to run when user wants to take a screenshot"; description = "command to run when user wants to take a screenshot";
}; };
}; };
@ -173,20 +173,24 @@ in
packageUnwrapped = null; packageUnwrapped = null;
suggestedPrograms = [ suggestedPrograms = [
"guiApps" "guiApps"
"conky" # for a nice background
"splatmoji" # used by us, but 'enabling' it gets us persistence & cfg
"swaylock"
"swayidle"
"wl-clipboard"
"blueberry" # GUI bluetooth manager "blueberry" # GUI bluetooth manager
"playerctl" # for waybar & particularly to have playerctld running "brightnessctl"
# "mako" # notification daemon "conky" # for a nice background
"swaynotificationcenter" # notification daemon "fuzzel"
"wob" # render volume changes on-screen
# "gnome.gnome-bluetooth" # XXX(2023/05/14): broken # "gnome.gnome-bluetooth" # XXX(2023/05/14): broken
# "gnome.gnome-control-center" # XXX(2023/06/28): depends on webkitgtk4_1 # "gnome.gnome-control-center" # XXX(2023/06/28): depends on webkitgtk4_1
"sway-contrib.grimshot" "playerctl" # for waybar & particularly to have playerctld running
"pulsemixer" # for volume controls
"splatmoji" # used by sway config
"sway-contrib.grimshot" # used by sway config
# "swayidle" # enable if you need it
"swaylock" # used by sway config
"swaynotificationcenter" # notification daemon
"waybar" # used by sway config
"wdisplays" # like xrandr "wdisplays" # like xrandr
"wl-clipboard"
"wob" # render volume changes on-screen
"xdg-terminal-exec" # used by sway config
]; ];
secrets.".config/sane-sway/snippets.txt" = ../../../../secrets/common/snippets.txt.bin; secrets.".config/sane-sway/snippets.txt" = ../../../../secrets/common/snippets.txt.bin;

View File

@ -1,31 +1,37 @@
{ config { config
, substituteAll , substituteAll
, swayCfg , swayCfg
, writeShellScript , writeShellApplication
}: }:
let let
prog = config.sane.programs; prog = config.sane.programs;
# TODO: stop referring to all of these by absolute path. # TODO: move all of this inline into the non-nix sway-config
fuzzel = "${prog.fuzzel.package}/bin/fuzzel"; launcher_cmd = "fuzzel";
sed = "${prog.gnused.package}/bin/sed"; terminal_cmd = "xdg-terminal-exec";
wtype = "${prog.wtype.package}/bin/wtype"; lock_cmd = "swaylock --indicator-idle-visible --indicator-radius 100 --indicator-thickness 30";
launcher_cmd = fuzzel;
terminal_cmd = "${prog.xdg-terminal-exec.package}/bin/xdg-terminal-exec";
lock_cmd = "${prog.swaylock.package}/bin/swaylock --indicator-idle-visible --indicator-radius 100 --indicator-thickness 30";
# TODO: use pipewire controls? # TODO: use pipewire controls?
vol_up_cmd = "${prog.pulsemixer.package}/bin/pulsemixer --change-volume +5"; vol_up_cmd = "pulsemixer --change-volume +5";
vol_down_cmd = "${prog.pulsemixer.package}/bin/pulsemixer --change-volume -5"; vol_down_cmd = "pulsemixer --change-volume -5";
mute_cmd = "${prog.pulsemixer.package}/bin/pulsemixer --toggle-mute"; mute_cmd = "pulsemixer --toggle-mute";
# "bookmarking"/snippets inspired by Luke Smith: # "bookmarking"/snippets inspired by Luke Smith:
# - <https://www.youtube.com/watch?v=d_11QaTlf1I> # - <https://www.youtube.com/watch?v=d_11QaTlf1I>
snip_cmd = writeShellScript "type_snippet.sh" '' snip_cmd_pkg = writeShellApplication {
snippet=$(cat ${../snippets.txt} ~/.config/sane-sway/snippets.txt | \ name = "type-snippet";
${fuzzel} -d -i -w 60 | \ runtimeInputs = [
${sed} 's/ #.*$//') prog.fuzzel.package
${wtype} "$snippet" prog.gnused.package
''; prog.wtype.package
];
text = ''
snippet=$(cat ${../snippets.txt} ~/.config/sane-sway/snippets.txt | \
fuzzel -d -i -w 60 | \
sed 's/ #.*$//')
wtype "$snippet"
'';
};
snip_cmd = "${snip_cmd_pkg}/bin/type-snippet";
# TODO: splatmoji release > 1.2.0 should allow `-s none` to disable skin tones # TODO: splatmoji release > 1.2.0 should allow `-s none` to disable skin tones
emoji_cmd = "${prog.splatmoji.package}/bin/splatmoji -s medium-light type"; emoji_cmd = "splatmoji -s medium-light type";
in substituteAll { in substituteAll {
src = ./sway-config; src = ./sway-config;
inherit inherit
@ -49,6 +55,6 @@ in substituteAll {
workspace_layout workspace_layout
; ;
xwayland = if swayCfg.xwayland then "enable" else "disable"; xwayland = if swayCfg.xwayland then "enable" else "disable";
playerctl = "${prog.playerctl.package}/bin/playerctl"; playerctl = "playerctl";
waybar = "${prog.waybar.package}/bin/waybar"; waybar = "waybar";
} }