Add dmenu scripts

This commit is contained in:
2024-06-05 19:02:33 +01:00
parent 53d38e93e7
commit e672a7003f
6 changed files with 133 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# dmenu theming
lines="-l 20"
selected="$(ps -a -u $USER | \
dmenu -i -p "Type to search and select process to kill" \
$lines | \
awk '{print $1" "$4}')";
if [[ ! -z $selected ]]; then
answer="$(echo -e "Yes\nNo" | \
dmenu -i -p "$selected will be killed, are you sure?" \
$lines )"
if [[ $answer == "Yes" ]]; then
selpid="$(awk '{print $1}' <<< $selected)";
kill -9 $selpid
fi
fi
exit 0

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
prompt="-p Manual:"
# terminal to open manual
terminal="st"
# list all manuals
manual="$(man -k . | dmenu $prompt | awk '{print $1}')"
# open selected manual with terminal
if [[ ! -z "$manual" ]]; then
eval "$($terminal -e man $manual)"
fi
exit 0

17
dotfiles/.local/bin/dmenu-menus Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
script_path="$HOME/.local/bin"
prompt="-p Menus:"
# list only executable non-binay files
run_dmenu="$(find $script_path/dmenu-* -maxdepth 1 -type f -executable \
-exec grep -Iq . {} \; -print \
| sed 's|^'$script_path/'||' \
| sort \
| dmenu $prompt)"
eval "$script_path/$run_dmenu"
exit 0

View File

@@ -82,7 +82,7 @@ def dmenu_pass(command, color):
return ["-P"] if dm_patch else ["-nb", color, "-nf", color] return ["-P"] if dm_patch else ["-nb", color, "-nf", color]
def dmenu_cmd(num_lines, prompt="Networks", active_lines=None): def dmenu_cmd(num_lines=20, prompt="Networks", active_lines=None):
"""Parse config.ini for menu options """Parse config.ini for menu options
Args: args - num_lines: number of lines to display Args: args - num_lines: number of lines to display

View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
sources_file="$HOME/.local/bin/dmenu-websearch-sources"
prompt="-p Search:"
se_data="$(
awk -F'"' '
BEGIN {
labels=""
}
{
# Selector line
gsub(/[[:space:]]/,"",$1)
sel=$1
# Description line
dsc=$2
# URL line
gsub(/[[:space:]]/,"",$3)
url=$3
# URL array (selector is the key)
surl[sel]=url
# Descriptions array (selector is the key)
sdsc[sel]=dsc
if (labels != "") {
labels=sprintf ("%s\n%s - %s", labels, sel, dsc)
} else {
labels=sprintf ("%s - %s", sel, dsc)
}
}
END {
for(k in surl) {
print "declare -A " k
print k "[url]=\"" surl[k] "\""
print k "[dsc]=\"" sdsc[k] "\""
}
print "dmenu_labels=\"" labels "\""
}
' "$sources_file"
)";
# Eval awk output as real variables...
eval "$se_data"
# Output label string to rofi...
search="$(dmenu $prompt <<< $dmenu_labels)"
if [[ ! -z "$search" ]]; then
# Retrieve data...
sel="$( awk '{ print tolower($1) }' <<< $search )"
txt="$( cut -d" " -f2- <<< $search )"
eval "sen_dsc=\"\${$sel[dsc]}\""
eval "sen_url=\"\${$sel[url]}\""
xdg-open "$sen_url$txt" &>/dev/null &
fi
exit 0

View File

@@ -0,0 +1,8 @@
gg "Google Search" https://www.google.com/search?q=
dd "DuckDuckGo" https://duckduckgo.com/?q=
we "Wikipedia (en)" https://en.wikipedia.org/wiki/
wp "Wikipedia (pt)" https://pt.wikipedia.org/wiki/
so "Stack Overflow" https://stackoverflow.com/search?q=
dl "DeepL Translator" https://www.deepl.com/translator#en/pt/
gt "Google Translate" https://translate.google.com.br/?text=
rd "Reverso Context Dictionay" https://context.reverso.net/traducao/ingles-portugues/