sway: split snippets into own program (rofi-snippets)

This commit is contained in:
Colin 2024-02-28 14:44:05 +00:00
parent c380f61bea
commit d912190db5
6 changed files with 34 additions and 27 deletions

View File

@ -104,4 +104,25 @@ in
"xdg-utils"
];
};
sane.programs.rofi-snippets = {
packageUnwrapped = pkgs.static-nix-shell.mkBash {
pname = "rofi-snippets";
srcRoot = ./.;
pkgs = [
"gnused"
"rofi"
"wtype"
];
};
# if i could remove the sed, then maybe possible to not sandbox.
sandbox.method = "bwrap";
sandbox.wrapperType = "wrappedDerivation";
sandbox.whitelistWayland = true;
suggestedPrograms = [ "rofi" ];
fs.".config/rofi-snippets/public.txt".symlink.target = ./snippets.txt;
secrets.".config/rofi-snippets/private.txt" = ../../../../secrets/common/snippets.txt.bin;
};
}

View File

@ -0,0 +1,10 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gnused -p rofi -p wtype
# "bookmarking"/snippets inspired by Luke Smith:
# - <https://www.youtube.com/watch?v=d_11QaTlf1I>
snippet=$(cat ~/.config/rofi-snippets/public.txt ~/.config/rofi-snippets/private.txt | \
rofi -dmenu | \
sed 's/ #.*$//')
wtype "$snippet"

View File

@ -115,6 +115,7 @@ in
"playerctl" # for waybar & particularly to have playerctld running
"pulsemixer" # for volume controls
"rofi" # menu/launcher
"rofi-snippets"
"splatmoji" # used by sway config
"sway-contrib.grimshot" # used by sway config
# "swayidle" # enable if you need it
@ -146,8 +147,6 @@ in
"xdg-terminal-exec" # used by sway config
];
secrets.".config/sane-sway/snippets.txt" = ../../../../secrets/common/snippets.txt.bin;
fs.".config/xdg-desktop-portal/sway-portals.conf".symlink.text = ''
# portals.conf docs: <https://flatpak.github.io/xdg-desktop-portal/docs/portals.conf.html>
[preferred]

View File

@ -14,7 +14,7 @@ set $term xdg-terminal-exec
set $menu rofi -show
set $emoji_picker splatmoji -s medium-light type
set $locker swaylock --indicator-idle-visible --indicator-radius 100 --indicator-thickness 30
set $snippets_picker @snip_cmd@
set $snippets_picker rofi-snippets
set $screenshot @screenshot_cmd@
set $brightness_up brightnessctl set +5%
set $brightness_down brightnessctl set 5%-

View File

@ -1,32 +1,9 @@
{ config
, substituteAll
, swayCfg
, writeShellApplication
}:
let
# TODO: port this snip_cmd_pkg to an ordinary `sane.programs`
prog = config.sane.programs;
# "bookmarking"/snippets inspired by Luke Smith:
# - <https://www.youtube.com/watch?v=d_11QaTlf1I>
snip_cmd_pkg = writeShellApplication {
name = "type-snippet";
runtimeInputs = [
prog.rofi.package
prog.gnused.package
prog.wtype.package
];
text = ''
snippet=$(cat ${./snippets.txt} ~/.config/sane-sway/snippets.txt | \
rofi -dmenu | \
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
in substituteAll {
substituteAll {
src = ./sway-config;
inherit snip_cmd;
inherit (swayCfg)
background
extra_lines