diff --git a/hosts/common/programs/rofi/default.nix b/hosts/common/programs/rofi/default.nix index 02174334..6293a4ab 100644 --- a/hosts/common/programs/rofi/default.nix +++ b/hosts/common/programs/rofi/default.nix @@ -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; + }; } diff --git a/hosts/common/programs/rofi/rofi-snippets b/hosts/common/programs/rofi/rofi-snippets new file mode 100755 index 00000000..375494b9 --- /dev/null +++ b/hosts/common/programs/rofi/rofi-snippets @@ -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: +# - + +snippet=$(cat ~/.config/rofi-snippets/public.txt ~/.config/rofi-snippets/private.txt | \ + rofi -dmenu | \ + sed 's/ #.*$//') +wtype "$snippet" diff --git a/hosts/common/programs/sway/snippets.txt b/hosts/common/programs/rofi/snippets.txt similarity index 100% rename from hosts/common/programs/sway/snippets.txt rename to hosts/common/programs/rofi/snippets.txt diff --git a/hosts/common/programs/sway/default.nix b/hosts/common/programs/sway/default.nix index 5ee96cad..eec926e0 100644 --- a/hosts/common/programs/sway/default.nix +++ b/hosts/common/programs/sway/default.nix @@ -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: [preferred] diff --git a/hosts/common/programs/sway/sway-config b/hosts/common/programs/sway/sway-config index b4351020..ea2c0307 100644 --- a/hosts/common/programs/sway/sway-config +++ b/hosts/common/programs/sway/sway-config @@ -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%- diff --git a/hosts/common/programs/sway/sway-config.nix b/hosts/common/programs/sway/sway-config.nix index 04b91fb5..2e947947 100644 --- a/hosts/common/programs/sway/sway-config.nix +++ b/hosts/common/programs/sway/sway-config.nix @@ -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: - # - - 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