diff --git a/dotfiles/.local/bin/dmenu-kill-process b/dotfiles/.local/bin/dmenu-kill-process new file mode 100755 index 00000000..eb47e813 --- /dev/null +++ b/dotfiles/.local/bin/dmenu-kill-process @@ -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 diff --git a/dotfiles/.local/bin/dmenu-mansearch b/dotfiles/.local/bin/dmenu-mansearch new file mode 100755 index 00000000..c65bfd61 --- /dev/null +++ b/dotfiles/.local/bin/dmenu-mansearch @@ -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 + + diff --git a/dotfiles/.local/bin/dmenu-menus b/dotfiles/.local/bin/dmenu-menus new file mode 100755 index 00000000..fa3fa694 --- /dev/null +++ b/dotfiles/.local/bin/dmenu-menus @@ -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 diff --git a/dotfiles/.local/bin/networkmanager_dmenu b/dotfiles/.local/bin/dmenu-networkmanager similarity index 99% rename from dotfiles/.local/bin/networkmanager_dmenu rename to dotfiles/.local/bin/dmenu-networkmanager index 4eb83bd5..fd6beb39 100755 --- a/dotfiles/.local/bin/networkmanager_dmenu +++ b/dotfiles/.local/bin/dmenu-networkmanager @@ -82,7 +82,7 @@ def dmenu_pass(command, 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 Args: args - num_lines: number of lines to display diff --git a/dotfiles/.local/bin/dmenu-websearch b/dotfiles/.local/bin/dmenu-websearch new file mode 100755 index 00000000..5b25e916 --- /dev/null +++ b/dotfiles/.local/bin/dmenu-websearch @@ -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 diff --git a/dotfiles/.local/bin/dmenu-websearch-sources b/dotfiles/.local/bin/dmenu-websearch-sources new file mode 100755 index 00000000..79f6f25b --- /dev/null +++ b/dotfiles/.local/bin/dmenu-websearch-sources @@ -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/