Move scripts into respective directories

Having a general script folder makes little sense if the scripts are
targeted to specific applications. This commit moved every script that
solely, or mainly (like ueberzug), targets a single application into
that respective stow module.
This commit is contained in:
Marty Oehme 2020-02-08 19:10:03 +01:00
parent 7d60a61565
commit 97f7fcbbd6
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A
10 changed files with 2 additions and 44 deletions

View file

@ -1,15 +0,0 @@
#!/bin/sh
# A dmenu binary prompt script.
# Gives a dmenu prompt labeled with $1 to perform command $2.
# For example:
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
if [[ -z $3 ]] || [[ $3 == "normal" ]]; then
[ "$(printf "No\\nYes" | dmenu -i -p "$1")" = "Yes" ] && $2
elif [[ $3 == "success" ]]; then
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb webgreen -sb greenyellow -sf black -nf white )" = "Yes" ] && $2
elif [[ $3 == "warn" ]] || [[ $3 == "warning" ]]; then
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb goldenrod -sb gold -sf black -nf white )" = "Yes" ] && $2
elif [[ $3 == "danger" ]]; then
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2
fi

View file

@ -1,27 +0,0 @@
#!/bin/bash
# toggle the translucency of inactive windows in the picom compositor
# by substituting the true/false setting in the picom config file.
# picom will automatically reload its settings on any config file changes.
#
# scipt can be called without arguments to toggle the value;
# or with on / off to set it to translucent / opaque, respectively.
piconf="$XDG_CONFIG_HOME"/picom/picom.conf
line=$(grep -n "inactive-opacity-override" "$piconf")
IFS=: read -r line text < <(grep -n "inactive-opacity-override" "$piconf")
_replace() { # line file old new
sed -i "$1 s/$3/$4/" "$2"
}
if [ "$1" = "off" ]; then
_replace "$line" "$piconf" "true" "false"
elif [ "$1" = "on" ]; then
_replace "$line" "$piconf" "false" "true"
elif echo "$text" | grep -q "true"; then
_replace "$line" "$piconf" "true" "false"
elif echo "$text" | grep -q "false"; then
_replace "$line" "$piconf" "false" "true"
fi

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
startbars() {
for bar in "$@"; do
local logfile="/tmp/polybar-$bar.log"
printf -- "---\npolybar: %s starting...\n---\n" "$bar" | tee -a "$logfile"
polybar "$bar" >>"$logfile" 2>&1 &
done
}
startbars "$@"
echo "Polybars launched..."

View file

@ -1,48 +0,0 @@
#!/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

View file

@ -1,240 +0,0 @@
#!/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

View file

@ -1,86 +0,0 @@
#!/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

View file

@ -1,12 +0,0 @@
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ueberzug==18.1.5','console_scripts','ueberzug'
__requires__ = 'ueberzug==18.1.5'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('ueberzug==18.1.5', 'console_scripts', 'ueberzug')()
)

View file

@ -1,154 +0,0 @@
#!/usr/bin/env bash
readonly ID_PREVIEW="preview"
#PLAY_GIF="yes"
# By enabling this option the GIF will be animated, by leaving it commented like it
# is now will make the gif previews behave the same way as video previews.
#AUTO_REMOVE="yes"
# By enabling this option the script will remove the preview file after it is drawn
# and by doing so the preview will always be up-to-date with the file.
# This however, requires more CPU and therefore affects the overall performance.
# The messy code below is for moving pages in pdf files in the vifm file preview by
# utilizing the < and > keys which will be bound to `vifmimg inc` or `vifmimg dec`.
PDF_PAGE_CONFIG="$HOME/.config/vifm/vifmimgpdfpage"
PDF_FILE_CONFIG="$HOME/.config/vifm/vifmimgpdffile"
PDF_PAGE=1
PDF_FILE=""
# Initialize the variables and required files
[[ -f "$PDF_PAGE_CONFIG" ]] && PDF_PAGE=$(cat $PDF_PAGE_CONFIG) || touch $PDF_PAGE_CONFIG
[[ -f "$PDF_FILE_CONFIG" ]] && PDF_FILE=$(cat $PDF_FILE_CONFIG) || touch $PDF_FILE_CONFIG
# Create temporary working directory if the directory structure doesn't exist
if [[ ! -d "/tmp$PWD/" ]]; then
mkdir -p "/tmp$PWD/"
fi
function inc() {
VAL="$(cat $PDF_PAGE_CONFIG)"
echo "$(expr $VAL + 1)" > $PDF_PAGE_CONFIG
}
function dec() {
VAL="$(cat $PDF_PAGE_CONFIG)"
echo "$(expr $VAL - 1)" > $PDF_PAGE_CONFIG
if [[ $VAL -le 0 ]]; then
echo 0 > $PDF_PAGE_CONFIG
fi
}
function previewclear() {
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \
> "$FIFO_UEBERZUG"
}
function fileclean() {
if [[ -f "/tmp$PWD/$6.png" ]]; then
rm -f "/tmp$PWD/$6.png"
elif [[ -d "/tmp$PWD/$6/" ]]; then
rm -rf "/tmp$PWD/$6/"
fi
}
function preview() {
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="$PWD/$6") \
> "$FIFO_UEBERZUG"
}
function previewvideo() {
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10
fi
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="/tmp$PWD/$6.png") \
> "$FIFO_UEBERZUG"
}
function previewepub() {
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
epub-thumbnailer "$6" "/tmp$PWD/$6.png" 1024
fi
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="/tmp$PWD/$6.png") \
> "$FIFO_UEBERZUG"
}
function previewgif() {
if [[ ! -d "/tmp$PWD/$6/" ]]; then
mkdir -p "/tmp$PWD/$6/"
convert -coalesce "$PWD/$6" "/tmp$PWD/$6/$6.png"
fi
if [[ ! -z "$PLAY_GIF" ]]; then
for frame in $(ls -1 /tmp$PWD/$6/$6*.png | sort -V); do
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="$frame") \
> "$FIFO_UEBERZUG"
# Sleep between frames to make the animation smooth.
sleep .07
done
else
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="/tmp$PWD/$6/$6-0.png") \
> "$FIFO_UEBERZUG"
fi
}
function previewpdf() {
if [[ ! "$6" == "$PDF_FILE" ]]; then
PDF_PAGE=1
echo 1 > $PDF_PAGE_CONFIG
rm -f "/tmp$PWD/$6.png"
fi
if [[ ! "$PDF_PAGE" == "1" ]] && [[ -f "/tmp$PWD/$6.png" ]]; then
rm -f "/tmp$PWD/$6.png"
fi
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
pdftoppm -png -f $PDF_PAGE -singlefile "$6" "/tmp$PWD/$6"
fi
echo "$6" > $PDF_FILE_CONFIG
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="/tmp$PWD/$6.png") \
> "$FIFO_UEBERZUG"
}
function previewmagick() {
if [[ ! -f "/tmp$PWD/$6.png" ]]; then
convert -thumbnail $(identify -format "%wx%h" "$6") "$PWD/$6" "/tmp$PWD/$6.png"
fi
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
[path]="/tmp$PWD/$6.png") \
> "$FIFO_UEBERZUG"
}
function main() {
case "$1" in
"inc") inc "$@" ;;
"dec") dec "$@" ;;
"clear") previewclear "$@" ;;
"clean") fileclean "$@" ;;
"draw") preview "$@" ;;
"videopreview") previewvideo "$@" ;;
"epubpreview") previewepub "$@" ;;
"gifpreview") previewgif "$@" ;;
"pdfpreview") previewpdf "$@" ;;
"magickpreview") previewmagick "$@" ;;
"*") echo "Unknown command: '$@'" ;;
esac
}
main "$@"

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
function cleanup {
rm "$FIFO_UEBERZUG" 2>/dev/null
pkill -P $$ 2>/dev/null
}
pkill -P $$ 2>/dev/null
rm "$FIFO_UEBERZUG" 2>/dev/null
mkfifo "$FIFO_UEBERZUG" >/dev/null
trap cleanup EXIT 2>/dev/null
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash 2>&1 >/dev/null &
vifm $1
cleanup