Switch to GNU stow

This commit is contained in:
Marty Oehme 2019-12-29 23:12:13 +01:00
parent a2605c4254
commit d34cecb27e
137 changed files with 39244 additions and 141 deletions

View file

@ -0,0 +1,47 @@
#!/usr/bin/env sh
# Original wrapper script from: https://github.com/wstam88/rofi-fontawesome
# more fa icon lists can be obtained there as well
# a file to read from, will be preferred over url
# ROFI_FONTAWESOME_LIST_FILE="some-fa5-icon-list.txt"
# a url to pull list from
# ROFI_FONTAWESOME_LIST_URL="https://point-me-to/a/fa-icon-list.txt"
# icon|name|unicode, icon is default
# ROFI_FONTAWESOME_OUTPUT="icon"
if [ -n "$*" ]; then
output="${ROFI_FONTAWESOME_OUTPUT}"
case "$output" in
unicode)
printf "%s" "$*" |
grep -o -e '&#xf...;' |
sed 's/^&#x//' |
sed 's/;$//' |
xclip -selection clipboard >/dev/null 2>/dev/null &
;;
name)
printf "%s" "$*" |
cut -d\' -f2 |
xclip -selection clipboard >/dev/null 2>/dev/null &
;;
icon | *)
printf "%s" "$*" |
grep -o -e '&#xf...;' |
sed 's/^&#x/\\u/' |
sed 's/;$//' |
xclip -selection clipboard >/dev/null 2>/dev/null &
;;
esac
exit 0
elif [ -z "$*" ]; then
printf "\x00prompt\x1fIcon> \n"
printf "\x00markup-rows\x1ftrue\n"
url=${ROFI_FONTAWESOME_LIST_URL:-"https://raw.githubusercontent.com/wstam88/rofi-fontawesome/master/fa5-icon-list.txt"}
if [ -n "${ROFI_FONTAWESOME_LIST_FILE}" ]; then
cat "$ROFI_FONTAWESOME_LIST_FILE"
elif [ -n "${url}" ]; then
curl -s "${url}"
fi
fi

73
rofi/.config/rofi/modes/gopass Executable file
View file

@ -0,0 +1,73 @@
#!/usr/bin/env sh
# Custom key bindings do not work in script-mode, use a wrapper instead
# Script at .local/bin/rofi-gopass
OLD_GOPASS_GPG_OPTS="$GOPASS_GPG_OPTS"
break_out() {
if [ "$1" -eq 1 ]; then
exit
fi
}
has_xclip() {
if (type xclip >/dev/null 2>&1); then
printf "Your system does not appear to support pasting to clipboard via xclip."
exit 1
else
return 0
fi
}
to_clipboard() {
has_xclip
value="$(gopass show "$1" "$2")"
printf "%s" "$value" | xclip -selection clipboard
notify-send "Password" "Copied pass for $2 to clipboard.\n"
exit
}
show_secrets() {
printf "%s" "$(gopass ls -fo)"
}
# get_key() {
# return echo "$*" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch --export-secret-keys 2>&1
# }
# check_gpg_key() {
# check_keyphrase=$(echo "$*" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch --export-secret-keys 2>&1)
# if echo "$check_keyphrase" | grep -q -e '.*<.*@.*>'; then
# printf "\x00prompt\x1fLogin> \n"
# show_secrets
# elif echo "$check_keyphrase" | grep -q -e "can't get input" - || echo "$check_keyphrase" | grep -q -e "error receiving key" -; then
# printf "\x00prompt\x1fMaster Passphrase> \n"
# printf "%s" "$check_keyphrase"
# else
# echo "passphrase successfully input, $check_keyphrase"
# fi
# }
# has_selected_login() {
# echo "this is passed to ls: $*"
# echo "grep reveals: $(gopass ls -f | grep -e "$*" -)"
# if grep "$(gopass ls -f | grep -q -e "$*" -)"; then
# echo "ls found something"
# true
# else
# false
# fi
# }
# if [ -z "$*" ]; then
# check_gpg_key "$*"
# elif has_selected_login "$*"; then
# echo "has selected login $*"
# else
# check_gpg_key "$*"
# fi
main() {
show_secrets
}
main

View file

@ -0,0 +1,37 @@
#!/usr/bin/env sh
# Nerdfont csv from: https://github.com/shanedabes/rofi-nerdfonts
# a file to read from, will be preferred over url
# ROFI_NERDFONT_LIST_FILE="point/to/nerdfont-chars.csv"
# a url to pull list from
# ROFI_NERDFONT_LIST_URL="https://point-me-to/a/nerd-icon-list.csv"
# icon|name, icon is default
# ROFI_NERDFONT_OUTPUT="icon"
if [ -n "$*" ]; then
output="${ROFI_NERDFONT_OUTPUT}"
case "$output" in
name)
printf "%s" "$*" |
cut -d',' -f2 |
xclip -selection clipboard >/dev/null 2>/dev/null &
;;
icon | *)
printf "%s" "$*" |
cut -d',' -f1 |
xclip -selection clipboard >/dev/null 2>/dev/null &
;;
esac
exit 0
elif [ -z "$*" ]; then
printf "\x00prompt\x1fIcon> \n"
printf "\x00markup-rows\x1ftrue\n"
url=${ROFI_NERDFONT_LIST_URL:-"https://raw.githubusercontent.com/shanedabes/rofi-nerdfonts/master/chars.csv"}
if [ -n "${ROFI_NERDFONT_LIST_FILE}" ]; then
cat "$ROFI_NERDFONT_LIST_FILE"
elif [ -n "${url}" ]; then
curl -s "${url}"
fi
fi

View file

@ -0,0 +1,76 @@
#!/usr/bin/env sh
#### Environment Variable Options ###
# Interface options
# ROFI_POWERMENU_SHOW_ICONS=1
# ROFI_POWERMENU_SHOW_TEXT=0
# Command options
# ROFI_POWERMENU_SHUTDOWN_CMD=""
# ROFI_POWERMENU_REBOOT_CMD=""
# ROFI_POWERMENU_LOCKSCREEN_CMD=""
# ROFI_POWERMENU_LOGOUT_CMD=""
# ROFI_POWERMENU_SUSPEND_CMD=""
#### Menu Options ###
if [ "${ROFI_POWERMENU_SHOW_TEXT:-0}" -eq 0 ] && [ "${ROFI_POWERMENU_SHOW_ICONS:-1}" -eq 0 ]; then
echo "You disabled both text and icons for rofi-powermenu, nothing can be shown."
exit 1
elif [ "${ROFI_POWERMENU_SHOW_ICONS:-1}" -eq 1 ]; then
power_off_btn=""
reboot_btn=""
lock_btn=""
suspend_btn="鈴"
logout_btn=""
fi
if [ "${ROFI_POWERMENU_SHOW_TEXT:-0}" -eq 1 ]; then
power_off_btn="${power_off_btn} Shut Down"
reboot_btn="${reboot_btn} Restart"
lock_btn="${lock_btn} Lock Screen"
suspend_btn="${suspend_btn} Suspend"
logout_btn="${logout_btn} Log Out"
fi
# grep -a since it assumes with our nullcodes etc that this is a binary file
# grep -o to only leave the things we grep for
case $(echo "$*" | grep -a -o -e "Shutdown" -e "Reboot" -e "Lockscreen" -e "Logout" -e "Suspend") in
"Shutdown")
if [ -n "$ROFI_POWERMENU_SHUTDOWN_CMD" ]; then eval "$ROFI_POWERMENU_SHUTDOWN_CMD"; else
systemctl poweroff
fi
;;
"Reboot")
if [ -n "$ROFI_POWERMENU_REBOOT_CMD" ]; then eval "$ROFI_POWERMENU_REBOOT_CMD"; else
systemctl reboot
fi
;;
"Lockscreen")
# Completely detach from the parent script
# If in/outputs are not redirected, rofi will wait for the forked process as well.
if [ -n "$ROFI_POWERMENU_LOCKSCREEN_CMD" ]; then eval "$ROFI_POWERMENU_LOCKSCREEN_CMD"; else
lockscreen rofi </dev/null >/dev/null 2>/dev/null &
fi
;;
"Logout")
if [ -n "$ROFI_POWERMENU_LOGOUT_CMD" ]; then eval "$ROFI_POWERMENU_LOGOUT_CMD"; else
i3-msg exit
fi
;;
"Suspend")
if [ -n "$ROFI_POWERMENU_SUSPEND_CMD" ]; then eval "$ROFI_POWERMENU_SUSPEND_CMD"; else
lockscreen rofi </dev/null >/dev/null 2>/dev/null &
systemctl suspend
fi
;;
esac
if [ -z "$*" ]; then
printf "\x00prompt\x1fPower> \n"
# we can use pango markup to hide text which we can then search. Neat!
printf "\0markup-rows\x1ftrue\n"
printf "<!-- Shutdown Poweroff --> %s\n" "$power_off_btn"
printf "<!-- Reboot Restart --> %s\n" "$reboot_btn"
printf "<!-- Lockscreen --> %s\n" "$lock_btn"
printf "<!-- Suspend Sleep --> %s\n" "$suspend_btn"
printf "<!-- Exit X Logout --> %s\n" "$logout_btn"
fi

View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
rofi_command="rofi"
original_args=("$@")
for ((i = 0; i <= "${#original_args[@]}"; i++)); do
if [ "${original_args[i]}" == "-color" ]; then
for ((j = 0; j <= "${#original_args[@]}"; j++)); do
if [ "${original_args[j]}" == "-theme" ]; then
echo "with theme: $i : ${original_args[i]} ${original_args[i + 1]}"
fi
done
fi
done
# for ((index = 0; index <= ${#lines_ary[@]}; index++)); do
# if [ "${lines_ary[index]}" == "Release:" ]; then
# echo "${lines_ary[index + 1]}"
# fi
# done
$rofi_command "${original_args[@]}"
# if [ -z "${color}" ]; then
# command rofi "${original_args[@]}"
# fi
# echo "color = ${color}"

View file

@ -0,0 +1,209 @@
#!/bin/bash
# rofi wrapper. Add custom settings here.
_rofi () {
rofi -dmenu -no-auto-select -i "$@"
}
# default settings
backend=ydotool
dotool_delay=200
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:-user :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}" user)" | _dotool type; exit ;;
"12") printf '%s' "$(gopass show --password "${entry}")" | _dotool type; exit ;
esac
do_menu "${entry}"
}
main

99
rofi/.config/rofi/modes/test Executable file
View file

@ -0,0 +1,99 @@
#!/usr/bin/env sh
# POSIX COMPLIANT EXAMPLE ROFI MODE SCRIPT
#### Options ###
power_off_btn=""
reboot_btn=""
lock_btn=""
suspend_btn="鈴"
logout_btn=""
# find out what the user has input
# pad both values with a simple p in front
# if query is empty it tries to compare nothing with quit otherwise
# i.e. the [ operator, which will error out
if [ p"$*" = p"quit" ]; then
exit 0
fi
if [ x"$*" = x"noot" ]; then
rofi-powermenu
exit 0
fi
# another way to see what the user has input
# grep -a since it assumes with our nullcodes etc that this is a binary file
# grep -o to only leave the things we grep for
case $(echo "$*" | grep -a -o -e "Shutdown" -e "Reboot" -e "Lockscreen" -e "Logout" -e "Suspend") in
"Shutdown")
# do shutdown
;;
"Reboot")
# do shutdown
;;
"Lockscreen")
# do shutdown
;;
"Logout")
# do shutdown
;;
"Suspend")
# do shutdown
;;
esac
if [ "$@" ]; then
# Override the previously set prompt.
printf "\x00prompt\x1fChange prompt\n"
for a in 1 2 3 4 5 6 7 8 9 10; do
echo "$a"
done
echo "quit"
else
printf "\x00prompt\x1fPower> \n"
# we can use pango markup to hide text which we can then search. Neat!
printf "\0markup-rows\x1ftrue\n"
# echo -en "\0urgent\x1f0,2\n"
# echo -en "\0active\x1f1\n"
# echo -en "\0message\x1fSpecial <b>bold</b>message\n"
printf "aap\0icon\x1ffolder\n"
printf "<!-- Shutdown Poweroff --> %s\0icon\x1fstart-here\n" "$power_off_btn"
printf "<!-- Reboot Restart --> %s\n" "$reboot_btn"
printf "<!-- Lockscreen --> %s\n" "$lock_btn"
printf "<!-- Suspend Sleep --> %s\n" "$suspend_btn"
printf "<!-- Exit X Logout --> %s\n" "$logout_btn"
echo "<b>Bold</b>"
echo "quit"
fi
##!/usr/bin/env sh
#### Options ###
#power_off=""
#reboot=""
#lock=""
#suspend_btn="鈴"
#logout_btn=""
## Variable passed to rofi
#chosen="$(printf "%s\n%s\n%s\n%s\n%s" "$power_off" "$reboot" "$lock" "$suspend_btn" "$logout_btn" | $rofi_command -dmenu -selected-row 2)"
#case $chosen in
#$power_off)
# systemctl poweroff
# ;;
#$reboot)
# systemctl reboot
# ;;
#$lock)
# lockscreen
# ;;
#$suspend_btn)
# systemctl suspend
# ;;
#$logout_btn)
# i3-msg exit
# ;;
#esac