extract dmenu and launcher

This commit is contained in:
Leonardo Eugênio 2022-08-19 20:40:39 -03:00
parent 270deeab42
commit 6d3d7e5d44
10 changed files with 59 additions and 29 deletions

View file

@ -1,11 +1,15 @@
{ config, lib, ... }: { config, lib, ... }:
(pkgs: _: { (pkgs: _:
bmenu = import ./bmenu.nix { inherit config pkgs lib; }; let import_script = (_: path: import (path) { inherit config pkgs lib; });
_diffr = import ./diffr.nix { inherit config pkgs lib; }; in lib.mapAttrs import_script {
kak-pager = import ./kak-pager.nix { inherit config pkgs lib; }; wdmenu = ./wdmenu.nix;
terminal = import ./terminal.nix { inherit config pkgs lib; }; wlauncher = ./wlauncher.nix;
wpass = import ./wpass.nix { inherit config pkgs lib; }; bmenu = ./bmenu.nix;
screenshotsh = import ./screenshotsh.nix { inherit config pkgs lib; }; _diffr = ./diffr.nix;
_gpg-unlock = import ./_gpg-unlock.nix { inherit config pkgs lib; }; kak-pager = ./kak-pager.nix;
br = import ./br.nix { inherit config pkgs lib; }; terminal = ./terminal.nix;
}) wpass = ./wpass.nix;
screenshotsh = ./screenshotsh.nix;
_gpg-unlock = ./_gpg-unlock.nix;
br = ./br.nix;
})

11
scripts/wdmenu.nix Normal file
View file

@ -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} "$@"
''

11
scripts/wlauncher.nix Normal file
View file

@ -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} "$@"
''

View file

@ -4,7 +4,7 @@ pkgs.writeShellScriptBin "wpass" ''
wtype=${pkgs.wtype}/bin/wtype wtype=${pkgs.wtype}/bin/wtype
# dmenu=${pkgs.bmenu}/bin/bmenu # dmenu=${pkgs.bmenu}/bin/bmenu
dmenu="rofi -dmenu -i" dmenu="wdmenu -i"
find_file() { find_file() {
${pkgs.fd}/bin/fd --strip-cwd-prefix '\.gpg$' | ${pkgs.fd}/bin/fd --strip-cwd-prefix '\.gpg$' |

View file

@ -53,6 +53,8 @@ in {
pass pass
dhist dhist
bmenu bmenu
wdmenu
wlauncher
volumesh volumesh
pamixer pamixer
libnotify libnotify

View file

@ -56,48 +56,48 @@ map global find 'd' ': find_delete<ret>' -docstring 'file to delete'
define-command -override -hidden find_file \ define-command -override -hidden find_file \
%{ evaluate-commands %sh{ %{ 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'" echo "edit '$line'"
done done
} } } }
define-command -override -hidden find_delete \ define-command -override -hidden find_delete \
%{ nop %sh{ %{ 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 \ define-command -override -hidden find_git_file \
%{ evaluate-commands %sh{ %{ 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'" echo "edit -existing '$line'"
done done
} } } }
define-command -override -hidden find_git_modified \ define-command -override -hidden find_git_modified \
%{ evaluate-commands %sh{ %{ 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'" echo "edit -existing '$line'"
done done
} } } }
define-command -override -hidden find_dir \ define-command -override -hidden find_dir \
%{ cd %sh{ %{ 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'" echo "edit '$line'"
done done
} } } }
define-command -override -hidden find_buffer \ define-command -override -hidden find_buffer \
%{ evaluate-commands %sh{ %{ 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'" echo "buffer '$line'"
done done
} } } }
define-command -override -hidden find_ripgrep \ define-command -override -hidden find_ripgrep \
%{ evaluate-commands %sh{ %{ evaluate-commands %sh{
patter=$( rofi -dmenu -i -p "Regex") patter=$( wdmenu -i -p "Regex")
rg --column -n "$patter" | rofi -dmenu -i | rg --column -n "$patter" | wdmenu -i |
perl -ne 'print "edit \"$1\" \"$2\" \"$3\" " if /(.+):(\d+):(\d+):/' perl -ne 'print "edit \"$1\" \"$2\" \"$3\" " if /(.+):(\d+):(\d+):/'
} } } }
@ -108,7 +108,7 @@ define-command -override -hidden find_line \
line=$( line=$(
printf "%s\n" "$kak_reg_a" | printf "%s\n" "$kak_reg_a" |
nl -ba -w1 | nl -ba -w1 |
rofi -dmenu -i -p "Line" | wdmenu -i -p "Line" |
cut -f1 cut -f1
) )
test -n "$line" && echo "${line}gx" test -n "$line" && echo "${line}gx"

View file

@ -1,5 +1,4 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }: {
{
# RNNoise is a noise supperssion neural network # RNNoise is a noise supperssion neural network
# Here we use it as a plugin for pipewire to create a virtual microphone # Here we use it as a plugin for pipewire to create a virtual microphone
config = { config = {

View file

@ -32,7 +32,8 @@ in {
}; };
"#window" = { "#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" ]; # children = map mkLiteral [ "prompt" "entry" ];
border = mkLiteral "2px solid"; border = mkLiteral "2px solid";
border-color = mkLiteral accent.color; border-color = mkLiteral accent.color;

View file

@ -3,7 +3,7 @@ let
inherit (import ./variables.nix) key theme color accent font; inherit (import ./variables.nix) key theme color accent font;
pulse_sink = pkgs.writeShellScriptBin "pulse_sink" '' pulse_sink = pkgs.writeShellScriptBin "pulse_sink" ''
#!/bin/sh #!/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) vol=$(${pkgs.pamixer}/bin/pamixer --get-volume)
case "$output" in case "$output" in
HDMI) HDMI)
@ -34,7 +34,7 @@ in {
config = { config = {
wayland.windowManager.sway = let wayland.windowManager.sway = let
mod = "Mod4"; mod = "Mod4";
menu = "rofi -show drun"; menu = "wlauncher";
terminal = "alacritty"; terminal = "alacritty";
# Utility funcion # Utility funcion
@ -52,8 +52,7 @@ in {
# ${i} = v; # ${i} = v;
# }) # })
# Ouput: {val1 = 1; val2 = 2;} # Ouput: {val1 = 1; val2 = 2;}
iforEach0mergeAttrsSet = list: func: iforEach0mergeAttrsSet = list: func: mergeAttrsSet (iforEach0 list func);
mergeAttrsSet (iforEach0 list func);
in { in {
enable = true; enable = true;
config = { config = {
@ -147,7 +146,7 @@ in {
"s" = "exec ${pulse_sink}/bin/pulse_sink"; "s" = "exec ${pulse_sink}/bin/pulse_sink";
}; };
passthrough = { passthrough = {
"${mod}+escape" = "mode default;exec notify-send 'Passthrough off'"; "${mod}+escape" = "mode default;exec notify-send 'Passthrough off'";
}; };
}; };
floating = { floating = {
@ -279,7 +278,8 @@ in {
"${mod}+Ctrl+Return" = "exec thunar"; "${mod}+Ctrl+Return" = "exec thunar";
"${mod}+x" = "kill"; "${mod}+x" = "kill";
"${mod}+m" = "mode audio"; "${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}+f" = "fullscreen toggle";
"${mod}+Shift+space" = "floating toggle"; "${mod}+Shift+space" = "floating toggle";
"${mod}+space" = "focus mode_toggle"; "${mod}+space" = "focus mode_toggle";

View file

@ -90,4 +90,6 @@ in rec {
host = "cloud.disroot.org"; host = "cloud.disroot.org";
pass = "disroot.org"; pass = "disroot.org";
}; };
dmenu = "bmenu";
} }