Switch to GNU stow
This commit is contained in:
parent
a2605c4254
commit
d34cecb27e
137 changed files with 39244 additions and 141 deletions
48
scripts/.local/bin/rofi/rofi-bang
Executable file
48
scripts/.local/bin/rofi/rofi-bang
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#
|
||||
# rofi-bang
|
||||
#
|
||||
|
||||
# Allows execution of arbitrary commands through rofi by
|
||||
# invoking shell scripts. These shell scripts can in turn
|
||||
# of course be other rofi commands, which allows the creation
|
||||
# of chained rofi executions (e.g. !c 1+2) to run a
|
||||
# calculator script within rofi and immediately execute it.
|
||||
# Hence, rofi-bang.
|
||||
|
||||
cwd="$XDG_CONFIG_HOME"/rofi
|
||||
if [ ! -d "$cwd" ]; then
|
||||
echo "The necessary directory at $HOME/.config/rofi is not set up correctly."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cmdfile="$cwd/rofi-bang-commands.csv"
|
||||
if [ ! -f "$cmdfile" ]; then
|
||||
echo "The nessesary file at $cwd/rofi-bang-commands.csv has not been found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Present the initial selection screen - but as soon as only one candidate is left exit out
|
||||
# since bangs are unique (!text will not be matched by anything else) it should automatically exit
|
||||
# whenever a bang has been typed
|
||||
selection=$(
|
||||
cut <"$cmdfile" -s -d ',' -f 1,2 |
|
||||
sed 's/,/: /' |
|
||||
printf "%s\n%s\n%s" "$(cat -)" "suffix that is not in cmd file" "one last entry" |
|
||||
rofi -dmenu -i -p "Run> " -theme "Arc-Dark" -auto-select |
|
||||
sed 's/: /,/' |
|
||||
head -n 1
|
||||
)
|
||||
# we did not select anything, just exit
|
||||
if [ -z "$selection" ]; then exit 0; fi
|
||||
|
||||
# we selected something, check if it is in the bang commands file
|
||||
# if it is, we should execute the bang
|
||||
is_bang=$(grep "$selection" "$cmdfile")
|
||||
if [ -n "$is_bang" ]; then
|
||||
cmd=$(echo "$is_bang" | cut -s -d ',' -f 4)
|
||||
echo "$cmd" | xargs --no-run-if-empty -I "{}" /bin/bash -c "{}"
|
||||
else
|
||||
echo "not implemented yet, should re-run rofi with the exact same settings"
|
||||
fi
|
||||
240
scripts/.local/bin/rofi/rofi-gopass
Executable file
240
scripts/.local/bin/rofi/rofi-gopass
Executable file
|
|
@ -0,0 +1,240 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Code belongs to https://github.com/carnager/rofi-pass/
|
||||
# Copyright (C) 2019 carnager
|
||||
|
||||
# rofi wrapper. Add custom settings here.
|
||||
_rofi() {
|
||||
rofi -dmenu -no-auto-select -i "$@" -theme /themes/dmenu
|
||||
}
|
||||
|
||||
# default settings
|
||||
backend=xdotool
|
||||
dotool_delay=20
|
||||
daemon_wait=2
|
||||
autotype_delay=2
|
||||
key_autotype="Return"
|
||||
key_usertype="Alt+2"
|
||||
key_passtype="Alt+3"
|
||||
key_actions="Alt+a"
|
||||
key_clipboard="Alt+1"
|
||||
key_fieldtype="Return"
|
||||
|
||||
# read config file
|
||||
get_config_file() {
|
||||
configs=("$ROFI_PASS_CONFIG"
|
||||
"$HOME/.config/rofi-pass/rofi-gopass.conf"
|
||||
"/etc/rofi-gopass.conf")
|
||||
|
||||
# return the first config file with a valid path
|
||||
for config in "${configs[@]}"; do
|
||||
# '! -z' is needed in case ROFI_PASS_CONFIG is not set
|
||||
if [[ ! -z "${config}" && -f "${config}" ]]; then
|
||||
printf "%s" "$config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Make sure ESC will always end the programm.
|
||||
# Call this function with "exit_check $?" after each rofi call.
|
||||
exit_check() {
|
||||
exit_value=$1
|
||||
if [[ "${exit_value}" == "1" ]]; then
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
clipboard() {
|
||||
local entry
|
||||
local key
|
||||
local value
|
||||
entry="${1}"
|
||||
key="${2}"
|
||||
value="$(gopass show "${entry}" "${key}")"
|
||||
printf '%s' "${value}" | xclip -sel clip
|
||||
notify-send "rofi-gopass" "Copied ${key} to clipboard\nClearing in 45 seconds."
|
||||
(
|
||||
sleep 45
|
||||
printf '%s' "" | xclip
|
||||
printf '%s' "" | xclip -selection clipboard | notify-send "rofi-gopass" "Clipboard cleared"
|
||||
) &
|
||||
exit
|
||||
}
|
||||
|
||||
_ydotoold() {
|
||||
if ! pgrep -x "ydotoold" >/dev/null; then
|
||||
# ydotoold blocks the terminal, so we need to background it.
|
||||
# Sadly this way we never know when the process finished starting up.
|
||||
# Until ydotoold receives proper daemonizing we add a sleep value here.
|
||||
ydotoold &
|
||||
sleep "${daemon_wait}"
|
||||
fi
|
||||
}
|
||||
|
||||
_dotool() {
|
||||
local mode
|
||||
local key
|
||||
mode="${1}"
|
||||
key="${2:-null}"
|
||||
case "${mode}" in
|
||||
"type")
|
||||
case "${backend}" in
|
||||
"xdotool") xdotool type --delay "${dotool_delay}" --file - ;;
|
||||
"ydotool")
|
||||
_ydotoold
|
||||
ydotool type --delay "${dotool_delay}" --file -
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"key")
|
||||
case "${backend}" in
|
||||
"xdotool") xdotool key "${key}" ;;
|
||||
"ydotool")
|
||||
_ydotoold
|
||||
ydotool key "${key}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
list_passwords() {
|
||||
gopass list --flat
|
||||
}
|
||||
|
||||
autopass() {
|
||||
local entry
|
||||
local autotype
|
||||
entry="${1}"
|
||||
autotype="$(gopass show "${entry}" autotype)"
|
||||
autotype="${autotype:-username :tab pass}"
|
||||
|
||||
for word in ${autotype}; do
|
||||
case "$word" in
|
||||
":tab") _dotool key Tab ;;
|
||||
":space") _dotool key " " ;;
|
||||
":delay") sleep "${autotype_delay}" ;;
|
||||
":enter") _dotool key enter ;;
|
||||
"pass") printf '%s' "$(gopass show --password "${entry}")" | _dotool type ;;
|
||||
*) printf '%s' "$(gopass show "${entry}" "${word}")" | _dotool type ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
list_keys() {
|
||||
# gopass has no option to only list keys, so we need to build the list ourselves.
|
||||
local entry
|
||||
local keys
|
||||
entry="${1}"
|
||||
keys="$(gopass show "${entry}")"
|
||||
printf '%s\n' "${keys}" | while read -r line; do
|
||||
if [[ "${line}" == *": "* ]]; then
|
||||
printf '%s\n' "${line%: *}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
edit_key() {
|
||||
local entry
|
||||
local keys
|
||||
entry="${1}"
|
||||
keys="$(list_keys "${entry}")"
|
||||
key_name=$(printf '%s\n' "${keys}" | _rofi -mesg "Enter new key or chose existing one")
|
||||
exit_check $?
|
||||
value_name=$(printf '%s' "" | _rofi -mesg "Enter Value for key \"${key_name}\"")
|
||||
exit_check $?
|
||||
if [[ -z "${key_name}" ]]; then
|
||||
printf '%s' "${value_name}" | gopass insert -a "${entry}" "${key_name}"
|
||||
else
|
||||
printf '%s' "${value_name}" | gopass insert "${entry}" "${key_name}"
|
||||
fi
|
||||
}
|
||||
|
||||
# For dangerous operations call this function first. You can provide a message as argument.
|
||||
# Example: confirm "Are you sure you want to delete entry?"
|
||||
confirm() {
|
||||
local message
|
||||
message="${1}"
|
||||
confirm_content=(
|
||||
"Yes"
|
||||
"No")
|
||||
|
||||
confirm_menu=$(printf '%s\n' "${confirm_content[@]}" | _rofi -mesg "${message}")
|
||||
exit_check $?
|
||||
case "${confirm_menu}" in
|
||||
"Yes") : ;;
|
||||
"No") exit ;;
|
||||
esac
|
||||
}
|
||||
|
||||
custom_type() {
|
||||
local entry
|
||||
local keys
|
||||
entry="${1}"
|
||||
keys="$(list_keys "${entry}")"
|
||||
key_name=$(printf '%s\n' "${keys}" | _rofi -kb-accept-entry "" -no-custom -kb-custom-1 "${key_clipboard}" -kb-custom-2 "${key_fieldtype}" -mesg "${key_clipboard}: Copy to Clipboard | ${key_fieldtype}: Type Field")
|
||||
local exit_value=$?
|
||||
exit_check "${exit_value}"
|
||||
case "${exit_value}" in
|
||||
"10") clipboard "${entry}" "${key_name}" ;;
|
||||
"11")
|
||||
printf '%s' "$(gopass show "${entry}" "${key_name}")" | _dotool type
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
do_menu() {
|
||||
local entry
|
||||
entry="${1}"
|
||||
action_menu_content=(
|
||||
"< Go Back"
|
||||
"---"
|
||||
"Show Fields"
|
||||
"Add/Edit Keys"
|
||||
"Generate New Password"
|
||||
"Delete Entry"
|
||||
)
|
||||
|
||||
action_menu="$(printf '%s\n' "${action_menu_content[@]}" | _rofi -no-custom -mesg "Selected Entry: ${entry}" -p '> ')"
|
||||
exit_value=$?
|
||||
exit_check "${exit_value}"
|
||||
|
||||
case "${action_menu}" in
|
||||
"< Go Back") main ;;
|
||||
"Show Fields") custom_type "${entry}" ;;
|
||||
"Add/Edit Keys") edit_key "${entry}" ;;
|
||||
"Delete Entry")
|
||||
confirm "Delete ${entry}?"
|
||||
gopass rm -f "${entry}"
|
||||
;;
|
||||
"Generate New Password")
|
||||
confirm "Generate a new password for ${entry}?"
|
||||
gopass generate -f "${entry}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
entry="$(list_passwords | _rofi -kb-accept-entry "" -kb-custom-1 "${key_autotype}" -kb-custom-2 "${key_usertype}" -kb-custom-3 "${key_passtype}" -kb-custom-4 "${key_actions}" -mesg "${key_autotype}: Autotype | ${key_usertype}: Type User | ${key_passtype}: Type Pass | ${key_actions}: More Actions")"
|
||||
exit_value=$?
|
||||
exit_check "${exit_value}"
|
||||
case "${exit_value}" in
|
||||
"10")
|
||||
autopass "${entry}"
|
||||
exit
|
||||
;;
|
||||
"11")
|
||||
printf '%s' "$(gopass show "${entry}" username)" | _dotool type
|
||||
exit
|
||||
;;
|
||||
"12")
|
||||
printf '%s' "$(gopass show --password "${entry}")" | _dotool type
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
do_menu "${entry}"
|
||||
}
|
||||
|
||||
main
|
||||
86
scripts/.local/bin/rofi/rofi-surfraw
Executable file
86
scripts/.local/bin/rofi/rofi-surfraw
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
#!/bin/bash
|
||||
|
||||
# source surfraw config
|
||||
source $HOME/.surfraw.conf
|
||||
|
||||
# load global files
|
||||
source /etc/rofi-surfraw.conf
|
||||
|
||||
# create local copy of custom searchengines
|
||||
if [[ ! -d $HOME/.config/rofi-surfraw ]]; then
|
||||
mkdir $HOME/.config/rofi-surfraw/searchengines
|
||||
fi
|
||||
if [[ ! -f $HOME/.config/rofi-surfraw/searchengines ]]; then
|
||||
cp /usr/share/doc/rofi-surfraw/searchengines $HOME/.config/rofi-surfraw/searchengines
|
||||
fi
|
||||
|
||||
# get local config
|
||||
if [[ -f $HOME/.config/rofi-surfraw/config ]]; then
|
||||
source $HOME/.config/rofi-surfraw/config
|
||||
fi
|
||||
|
||||
# get list of search engines from surfraw
|
||||
if [[ $@ == *"--no-list"* ]]; then
|
||||
:
|
||||
else
|
||||
# list=$(sr -elvi | awk '{ print "?"$1 }' | tail -n +2)
|
||||
list=$(sr -elvi | awk '{if (NR!=1) print "?"$1 }')
|
||||
fi
|
||||
|
||||
# get custom engines from text file
|
||||
if [[ $@ == *"--no-custom"* ]]; then
|
||||
:
|
||||
else
|
||||
# custom=$(cat $HOME/.config/rofi-surfraw/searchengines | awk -F ' - ' '{ print $1 }')
|
||||
custom=$(awk -F ' - ' '{ print $1 }' $HOME/.config/rofi-surfraw/searchengines)
|
||||
fi
|
||||
|
||||
main () {
|
||||
# Draw Menu
|
||||
HELP_MSG="<span color=\"$help_color\">Hit Ctrl+Space to complete Engine Name
|
||||
Searches without prepended engine use "${default}"</span>"
|
||||
elvi=$(echo -e "${list}\n${custom}" | rofi -dmenu -mesg "${HELP_MSG}" -p "Search > ")
|
||||
|
||||
# Some logic
|
||||
if [[ $elvi == "" ]]; then exit
|
||||
elif [[ $elvi == "!"* ]]; then
|
||||
entry=$(grep "$(echo "${elvi}" | awk '{ print $1 }')" "$HOME/.config/rofi-surfraw/searchengines")
|
||||
method=$(echo "${entry}" | awk -F ' - ' '{ print $2 }')
|
||||
bang=$(echo "${entry}" | awk -F ' - ' '{ print $3 }')
|
||||
search=$(echo "${elvi}" | awk '{$1=""; print $0}' | cut -c 2-)
|
||||
if [[ $method == "surfraw" ]]; then
|
||||
sr ${bang} ${search}
|
||||
elif [[ $method == "custom" ]]; then
|
||||
"$SURFRAW_graphical_browser" $SURFRAW_graphical_browser_args ${bang}"${search}"
|
||||
fi
|
||||
elif [[ $elvi == "?"* ]]; then
|
||||
name=$(echo "${elvi}" | awk '{ print $1 }' | cut -c 2-)
|
||||
search=$(echo "${elvi}" | awk '{$1=""; print $0}' | cut -c 2-)
|
||||
sr ${name} ${search}
|
||||
else
|
||||
if [[ $default == "!"* ]]; then
|
||||
entry=$(grep "$(echo "${default}" | awk '{ print $1 }')" "$HOME/.config/rofi-surfraw/searchengines")
|
||||
method=$(echo "${entry}" | awk -F ' - ' '{ print $2 }')
|
||||
bang=$(echo "${entry}" | awk -F ' - ' '{ print $3 }')
|
||||
else
|
||||
method="surfraw"
|
||||
bang="$default"
|
||||
fi
|
||||
search="${elvi}"
|
||||
if [[ $method == "surfraw" ]]; then
|
||||
sr ${bang} ${search}
|
||||
elif [[ $method == "custom" ]]; then
|
||||
"$SURFRAW_graphical_browser" $SURFRAW_graphical_browser_args ${bang}"${search}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $1 == "--help" ]]; then
|
||||
echo "rofi-surfraw - (C) 2015 Rasmus Steinke <rasi at xssn dot at>"
|
||||
echo "---"
|
||||
echo "--help this help"
|
||||
echo "--no-list do not show inbuild search engines"
|
||||
echo "--no-custom do not show custom search engines"
|
||||
else
|
||||
main
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue