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 {
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
paths = [ desktop-file configuredSway ];
passthru = {
@ -42,7 +42,7 @@ let
withBaseWrapper = config.programs.sway.wrapperFeatures.base;
withGtkWrapper = config.programs.sway.wrapperFeatures.gtk;
isNixOS = true;
# TODO: `enableXWayland = ...`?
# TODO: `enableXWayland = ...`?
};
in
{
@ -118,17 +118,17 @@ in
# TODO: split these into their own option scope
brightness_down_cmd = mkOption {
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";
};
brightness_up_cmd = mkOption {
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";
};
screenshot_cmd = mkOption {
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";
};
};
@ -173,20 +173,24 @@ in
packageUnwrapped = null;
suggestedPrograms = [
"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
"playerctl" # for waybar & particularly to have playerctld running
# "mako" # notification daemon
"swaynotificationcenter" # notification daemon
"wob" # render volume changes on-screen
"brightnessctl"
"conky" # for a nice background
"fuzzel"
# "gnome.gnome-bluetooth" # XXX(2023/05/14): broken
# "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
"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;

View File

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