Add wofi as my launcher

- The default sway launcher is dmenu, which uses xwayland and has poor
  compatability
- Wofi is more similar to rofi, but is gtk-based and therefore works on wayland
diff --git a/modules/launcher.nix b/modules/launcher.nix
new file mode 100644
index 0000000..3aa9a5a
--- /dev/null
+++ b/modules/launcher.nix
@@ -0,0 +1,17 @@
+{
+  pkgs,
+  home,
+  lib,
+  ...
+}: {
+  home = {
+    home = {
+      packages = [pkgs.wofi];
+      file.".config/wofi/config".source = ./launcher/config.toml;
+    };
+    wayland.windowManager.sway.config.keybindings = lib.mkOptionDefault {
+      "${home.wayland.windowManager.sway.config.modifier}+d" = "exec sh -c '${pkgs.procps}/bin/pkill wofi; ${pkgs.wofi}/bin/wofi'";
+      "${home.wayland.windowManager.sway.config.modifier}+minus" = "exec sh -c '${pkgs.procps}/bin/pkill wofi; ${./launcher/show-scratchpad.sh}'";
+    };
+  };
+}
diff --git a/modules/launcher/config.toml b/modules/launcher/config.toml
new file mode 100644
index 0000000..c1606ee
--- /dev/null
+++ b/modules/launcher/config.toml
@@ -0,0 +1,7 @@
+show = drun,run
+prompt = Run application
+allow_images = true
+allow_markup = true
+insensitive = true
+key_expand = Control_L
+line_wrap = word
diff --git a/modules/launcher/show-scratchpad.sh b/modules/launcher/show-scratchpad.sh
new file mode 100755
index 0000000..c7e999a
--- /dev/null
+++ b/modules/launcher/show-scratchpad.sh
@@ -0,0 +1,3 @@
+export id="$(swaymsg -t get_tree | jq -r '.nodes[].nodes[] | select(.name == "__i3_scratch").floating_nodes | reverse[] | ((.id | tostring) + "\t" + (.app_id // .window_properties.class) + "\t" + .name)' | wofi --show dmenu --prompt "Select window to restore" | awk '{print $1;}')"
+echo Showing $id
+swaymsg "[con_id=$id]" focus