From 6d3d7e5d44161346150a24c701693406f980b872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Fri, 19 Aug 2022 20:40:39 -0300 Subject: [PATCH] extract dmenu and launcher --- scripts/default.nix | 24 ++++++++++++++---------- scripts/wdmenu.nix | 11 +++++++++++ scripts/wlauncher.nix | 11 +++++++++++ scripts/wpass.nix | 2 +- user/home.nix | 2 ++ user/kak/usermode.kak | 18 +++++++++--------- user/rnnoise.nix | 3 +-- user/rofi.nix | 3 ++- user/sway.nix | 12 ++++++------ user/variables.nix | 2 ++ 10 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 scripts/wdmenu.nix create mode 100644 scripts/wlauncher.nix diff --git a/scripts/default.nix b/scripts/default.nix index 83cc79e..b5e0c78 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -1,11 +1,15 @@ { config, lib, ... }: -(pkgs: _: { - bmenu = import ./bmenu.nix { inherit config pkgs lib; }; - _diffr = import ./diffr.nix { inherit config pkgs lib; }; - kak-pager = import ./kak-pager.nix { inherit config pkgs lib; }; - terminal = import ./terminal.nix { inherit config pkgs lib; }; - wpass = import ./wpass.nix { inherit config pkgs lib; }; - screenshotsh = import ./screenshotsh.nix { inherit config pkgs lib; }; - _gpg-unlock = import ./_gpg-unlock.nix { inherit config pkgs lib; }; - br = import ./br.nix { inherit config pkgs lib; }; -}) +(pkgs: _: + let import_script = (_: path: import (path) { inherit config pkgs lib; }); + in lib.mapAttrs import_script { + wdmenu = ./wdmenu.nix; + wlauncher = ./wlauncher.nix; + bmenu = ./bmenu.nix; + _diffr = ./diffr.nix; + kak-pager = ./kak-pager.nix; + terminal = ./terminal.nix; + wpass = ./wpass.nix; + screenshotsh = ./screenshotsh.nix; + _gpg-unlock = ./_gpg-unlock.nix; + br = ./br.nix; + }) diff --git a/scripts/wdmenu.nix b/scripts/wdmenu.nix new file mode 100644 index 0000000..2f09513 --- /dev/null +++ b/scripts/wdmenu.nix @@ -0,0 +1,11 @@ +{ config, pkgs, lib, ... }: +let + inherit (pkgs.uservars) dmenu; + available_menus = { + bmenu = "bmenu"; + rofi = "rofi -dmenu"; + }; + menu_cmd = available_menus.${dmenu}; +in pkgs.writeShellScriptBin "wdmenu" '' + exec ${menu_cmd} "$@" +'' diff --git a/scripts/wlauncher.nix b/scripts/wlauncher.nix new file mode 100644 index 0000000..c54fc4e --- /dev/null +++ b/scripts/wlauncher.nix @@ -0,0 +1,11 @@ +{ config, pkgs, lib, ... }: +let + inherit (pkgs.uservars) dmenu; + available_menus = { + bmenu = "bmenu run"; + rofi = "rofi -show drun"; + }; + menu_cmd = available_menus.${dmenu}; +in pkgs.writeShellScriptBin "wlauncher" '' + exec ${menu_cmd} "$@" +'' diff --git a/scripts/wpass.nix b/scripts/wpass.nix index 1194f86..5176ff6 100644 --- a/scripts/wpass.nix +++ b/scripts/wpass.nix @@ -4,7 +4,7 @@ pkgs.writeShellScriptBin "wpass" '' wtype=${pkgs.wtype}/bin/wtype # dmenu=${pkgs.bmenu}/bin/bmenu - dmenu="rofi -dmenu -i" + dmenu="wdmenu -i" find_file() { ${pkgs.fd}/bin/fd --strip-cwd-prefix '\.gpg$' | diff --git a/user/home.nix b/user/home.nix index 0fddd43..6505ebc 100644 --- a/user/home.nix +++ b/user/home.nix @@ -53,6 +53,8 @@ in { pass dhist bmenu + wdmenu + wlauncher volumesh pamixer libnotify diff --git a/user/kak/usermode.kak b/user/kak/usermode.kak index 501e598..56b5ccb 100644 --- a/user/kak/usermode.kak +++ b/user/kak/usermode.kak @@ -56,48 +56,48 @@ map global find 'd' ': find_delete' -docstring 'file to delete' define-command -override -hidden find_file \ %{ evaluate-commands %sh{ - for line in `fd --strip-cwd-prefix -tf -HE .git | rofi -dmenu -i -p "File: "`; do + for line in `fd --strip-cwd-prefix -tf -HE .git | wdmenu -i -p "File: "`; do echo "edit '$line'" done } } define-command -override -hidden find_delete \ %{ nop %sh{ - fd --strip-cwd-prefix -H -E .git -t f | rofi -dmenu -i | xargs -r trash + fd --strip-cwd-prefix -H -E .git -t f | wdmenu -i | xargs -r trash } } define-command -override -hidden find_git_file \ %{ evaluate-commands %sh{ - for line in `git ls-files | rofi -dmenu -i`; do + for line in `git ls-files | wdmenu -i`; do echo "edit -existing '$line'" done } } define-command -override -hidden find_git_modified \ %{ evaluate-commands %sh{ - for line in `git status --porcelain | sd '^.. ' ''| rofi -dmenu -i`; do + for line in `git status --porcelain | sd '^.. ' ''| wdmenu -i`; do echo "edit -existing '$line'" done } } define-command -override -hidden find_dir \ %{ cd %sh{ - for line in `fd --strip-cwd-prefix -Htd | rofi -dmenu -i`; do + for line in `fd --strip-cwd-prefix -Htd | wdmenu -i`; do echo "edit '$line'" done } } define-command -override -hidden find_buffer \ %{ evaluate-commands %sh{ - for line in `printf "%s\n" $kak_buflist | rofi -dmenu -i`; do + for line in `printf "%s\n" $kak_buflist | wdmenu -i`; do echo "buffer '$line'" done } } define-command -override -hidden find_ripgrep \ %{ evaluate-commands %sh{ - patter=$( rofi -dmenu -i -p "Regex") - rg --column -n "$patter" | rofi -dmenu -i | + patter=$( wdmenu -i -p "Regex") + rg --column -n "$patter" | wdmenu -i | perl -ne 'print "edit \"$1\" \"$2\" \"$3\" " if /(.+):(\d+):(\d+):/' } } @@ -108,7 +108,7 @@ define-command -override -hidden find_line \ line=$( printf "%s\n" "$kak_reg_a" | nl -ba -w1 | - rofi -dmenu -i -p "Line" | + wdmenu -i -p "Line" | cut -f1 ) test -n "$line" && echo "${line}gx" diff --git a/user/rnnoise.nix b/user/rnnoise.nix index 746e189..1a3ce2b 100644 --- a/user/rnnoise.nix +++ b/user/rnnoise.nix @@ -1,5 +1,4 @@ -{ config, pkgs, lib, ... }: -{ +{ config, pkgs, lib, ... }: { # RNNoise is a noise supperssion neural network # Here we use it as a plugin for pipewire to create a virtual microphone config = { diff --git a/user/rofi.nix b/user/rofi.nix index e5d95ac..2d12146 100644 --- a/user/rofi.nix +++ b/user/rofi.nix @@ -32,7 +32,8 @@ in { }; "#window" = { - background-color = mkLiteral "${color.bg}${lib.toHexString (theme.opacity * 255 / 100)}"; + background-color = mkLiteral + "${color.bg}${lib.toHexString (theme.opacity * 255 / 100)}"; # children = map mkLiteral [ "prompt" "entry" ]; border = mkLiteral "2px solid"; border-color = mkLiteral accent.color; diff --git a/user/sway.nix b/user/sway.nix index 428e321..1488614 100644 --- a/user/sway.nix +++ b/user/sway.nix @@ -3,7 +3,7 @@ let inherit (import ./variables.nix) key theme color accent font; pulse_sink = pkgs.writeShellScriptBin "pulse_sink" '' #!/bin/sh - output=$(printf "HDMI\nHeadphones" | rofi -dmenu -i -p "Output:") + output=$(printf "HDMI\nHeadphones" | wdmenu -i -p "Output:") vol=$(${pkgs.pamixer}/bin/pamixer --get-volume) case "$output" in HDMI) @@ -34,7 +34,7 @@ in { config = { wayland.windowManager.sway = let mod = "Mod4"; - menu = "rofi -show drun"; + menu = "wlauncher"; terminal = "alacritty"; # Utility funcion @@ -52,8 +52,7 @@ in { # ${i} = v; # }) # Ouput: {val1 = 1; val2 = 2;} - iforEach0mergeAttrsSet = list: func: - mergeAttrsSet (iforEach0 list func); + iforEach0mergeAttrsSet = list: func: mergeAttrsSet (iforEach0 list func); in { enable = true; config = { @@ -147,7 +146,7 @@ in { "s" = "exec ${pulse_sink}/bin/pulse_sink"; }; passthrough = { - "${mod}+escape" = "mode default;exec notify-send 'Passthrough off'"; + "${mod}+escape" = "mode default;exec notify-send 'Passthrough off'"; }; }; floating = { @@ -279,7 +278,8 @@ in { "${mod}+Ctrl+Return" = "exec thunar"; "${mod}+x" = "kill"; "${mod}+m" = "mode audio"; - "${mod}+escape" = "mode passthrough;exec notify-send 'Passthrough on'"; + "${mod}+escape" = + "mode passthrough;exec notify-send 'Passthrough on'"; "${mod}+f" = "fullscreen toggle"; "${mod}+Shift+space" = "floating toggle"; "${mod}+space" = "focus mode_toggle"; diff --git a/user/variables.nix b/user/variables.nix index 0b9e5db..6738ad0 100644 --- a/user/variables.nix +++ b/user/variables.nix @@ -90,4 +90,6 @@ in rec { host = "cloud.disroot.org"; pass = "disroot.org"; }; + + dmenu = "bmenu"; }