wip
This commit is contained in:
104
dots/bin/obsolete/obsolete.dmenu_recency
Normal file
104
dots/bin/obsolete/obsolete.dmenu_recency
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
# src: https://github.com/manjaro/packages-community/blob/master/dmenu-manjaro/dmenu_recency
|
||||
|
||||
# Originally based on code by Dieter Plaetinck.
|
||||
# Pretty much re-written by Mina Nagy (mnzaki)
|
||||
# Edited by Chrysostomus to create/source .dmenurc
|
||||
|
||||
if ! [ -f "$HOME/.dmenurc" ]; then
|
||||
cp /usr/share/dmenu/dmenurc $HOME/.dmenurc
|
||||
fi
|
||||
. $HOME/.dmenurc
|
||||
|
||||
if [ -z "$TERMINAL_CMD" ]; then
|
||||
if [ "$(which terminal)" ]; then
|
||||
TERMINAL_CMD="terminal -e"
|
||||
elif [ "$(which urxvt)" ]; then
|
||||
TERMINAL_CMD="urxvt -e"
|
||||
elif [ "$(which termite)" ]; then
|
||||
TERMINAL_CMD="termite -e"
|
||||
elif [ "$(which terminator)" ]; then
|
||||
TERMINAL_CMD="terminator -e"
|
||||
elif [ "$(which gnome-terminal)" ]; then
|
||||
TERMINAL_CMD="gnome-terminal -e"
|
||||
elif [ "$(which lxterminal)" ]; then
|
||||
TERMINAL_CMD="lxterminal -e"
|
||||
elif [ "$(which sakura)" ]; then
|
||||
TERMINAL_CMD="sakura -e"
|
||||
elif [ "$(which xfce4-terminal)" ]; then
|
||||
TERMINAL_CMD="xfce4-terminal -e"
|
||||
elif [ "$(which xterm)" ]; then
|
||||
TERMINAL_CMD="xterm -e"
|
||||
elif [ "$(which kitty)" ]; then
|
||||
TERMINAL_CMD="kitty -e"
|
||||
fi
|
||||
fi
|
||||
|
||||
dmenu_cmd="dmenu $DMENU_OPTIONS"
|
||||
max_recent=199 # Number of recent commands to track
|
||||
|
||||
cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/dmenu-recent"
|
||||
recent_cache="$cache_dir/recent"
|
||||
rest_cache="$cache_dir/all"
|
||||
known_types=" background terminal terminal_hold "
|
||||
|
||||
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/dmenu-recent"
|
||||
mkdir -p "$cache_dir"
|
||||
mkdir -p "$config_dir"
|
||||
touch "$recent_cache"
|
||||
|
||||
# Without this, it won't remember $type
|
||||
GREP_OPTIONS='--color=never'
|
||||
|
||||
IFS=:
|
||||
if stest -dqr -n "$rest_cache" $PATH 2>/dev/null; then
|
||||
stest -flx $PATH | sort -u | grep -vf "$recent_cache" > "$rest_cache"
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
cmd=$(cat "$recent_cache" "$rest_cache" | $dmenu_cmd -p run: "$@") || exit
|
||||
|
||||
if ! grep -qx "$cmd" "$recent_cache" &> /dev/null; then
|
||||
grep -vx "$cmd" "$rest_cache" > "$rest_cache.$$"
|
||||
if -s "$rest_cache.$$"; then
|
||||
mv "$rest_cache.$$" "$rest_cache"
|
||||
else
|
||||
rm "$rest_cache.$$"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! $cmd == *[[]* ]]; then
|
||||
echo "$cmd" > "$recent_cache.$$"
|
||||
grep -vx "$cmd" "$recent_cache" | head -n "$max_recent" >> "$recent_cache.$$"
|
||||
mv "$recent_cache.$$" "$recent_cache"
|
||||
fi
|
||||
|
||||
# Figure out how to run the command based on the command name, disregarding
|
||||
# arguments, if any.
|
||||
word0=${cmd%% *}
|
||||
match="^$word0$"
|
||||
|
||||
get_type () {
|
||||
while type=$(echo $known_types | xargs -n1 | $dmenu_cmd -p Type:); do
|
||||
[[ $known_types =~ " $type " ]] || continue
|
||||
echo "$word0" >> "$config_dir/$type"
|
||||
break
|
||||
done
|
||||
echo $type
|
||||
}
|
||||
|
||||
if ! type=$(grep -lx "$match" -R "$config_dir"); then
|
||||
type=$(get_type)
|
||||
else
|
||||
type=${type##*/}
|
||||
if ! [[ $known_types =~ " $type " ]]; then
|
||||
rm "$config_dir/$type"
|
||||
type=$(get_type)
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ "$type" = "background" ]] && exec $cmd
|
||||
[[ "$type" = "terminal" ]] && exec $TERMINAL_CMD "$cmd"
|
||||
[[ "$type" = "terminal_hold" ]] &&
|
||||
exec $TERMINAL_CMD sh -c "$cmd && echo Press Enter to kill me... && read line"
|
||||
54
dots/bin/obsolete/obsolete.i3lock_fk.sh
Normal file
54
dots/bin/obsolete/obsolete.i3lock_fk.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# originally got the idea from this script:
|
||||
# src:https://github.com/veltall/custom-i3lock
|
||||
|
||||
# get random image to use
|
||||
# https://stackoverflow.com/questions/61290199/how-do-i-select-a-random-file-from-a-directory
|
||||
random_image=$(ls -1 /home/${USER}/.local/share/img/*.png | shuf | head -1)
|
||||
random_image_filname="$(basename -- $random_image)"
|
||||
|
||||
# get random gravity to use for the overlay image, take the number of displays into account
|
||||
# https://imagemagick.org/script/command-line-options.php#gravity
|
||||
# $ magick -list gravity
|
||||
numberOfDisplays=$(xrandr --query | grep -o " connected " | wc -l)
|
||||
gravity=("center") # "center" "northwest" "northeast" "southwest" "southeast"
|
||||
if [[ numberOfDisplays == 1 ]] || [[ numberOfDisplays == 3 ]] ; then
|
||||
gravity=("center" "northwest" "northeast" "southwest" "southeast")
|
||||
elif [[ numberOfDisplays == 2 ]] ; then
|
||||
gravity=("northeast" "southeast")
|
||||
else
|
||||
gravity=("east")
|
||||
fi
|
||||
random_gravity=${gravity[ $RANDOM % ${#gravity[@]} ]}
|
||||
|
||||
# take a screenshot of the entire screen, blur it, and adjust white balance
|
||||
scrot --overwrite /tmp/currentworkspace.png
|
||||
magick /tmp/currentworkspace.png -blur 0x9 /tmp/currentworkspaceblur.png
|
||||
mogrify -brightness-contrast 50 /tmp/currentworkspaceblur.png
|
||||
|
||||
# send a notification to the user after the screenshot is taken, to avoid including the notification
|
||||
notify-send "LOCKING SCREEN" "The system is about to be locked.\nPress any key to stop this from happening.\n\n${random_image_filname} @ ${random_gravity}"
|
||||
|
||||
# https://linuxsimply.com/bash-scripting-tutorial/input-output/input/wait-for-input/
|
||||
read -t 15 -n 1 key # read a single character within a X-seconds period
|
||||
if [ $? = 0 ]; then
|
||||
|
||||
notify-send "'${key}' is pressed ➔ the screen will not be locked"
|
||||
exit
|
||||
|
||||
else
|
||||
|
||||
# find height of background image, and set the overlay to be 1/3 of this
|
||||
workspaceHeight=$(magick /tmp/currentworkspaceblur.png -print "%h" /dev/null)
|
||||
overlayHeight=$((${workspaceHeight} / 3))
|
||||
|
||||
# resize the overlay image
|
||||
cp ${random_image} /tmp/overlayimage.png
|
||||
mogrify -resize x${overlayHeight} /tmp/overlayimage.png
|
||||
|
||||
# create the final image to be used as the lock screen, and lock the system
|
||||
composite -gravity ${random_gravity} /tmp/overlayimage.png /tmp/currentworkspaceblur.png /tmp/lockbackground.png
|
||||
i3lock --tiling -i /tmp/lockbackground.png
|
||||
|
||||
fi
|
||||
86
dots/bin/obsolete/obsolete.lfMultiSelectHandler.sh
Normal file
86
dots/bin/obsolete/obsolete.lfMultiSelectHandler.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# klevstul :: 25.04
|
||||
|
||||
this_file_name=`basename "$0"`
|
||||
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "error: path to file is missing."
|
||||
echo "usage: '$this_file_name [callback] [input_array]'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sync_dir_sym=/home/${USER}/syncDir
|
||||
syncdir_env_var=SYNCDIR_${HOSTNAME}
|
||||
sync_dir=${!syncdir_env_var} # '!' to use the name and not the value
|
||||
cwd=$(pwd)
|
||||
callback=$1
|
||||
|
||||
# echo
|
||||
# echo ">>> ${this_file_name} <<<"
|
||||
# echo
|
||||
# echo "DEBUG: debugging values:"
|
||||
# echo "DEBUG: input args (all): $@"
|
||||
# echo "DEBUG: input args (one by one):"
|
||||
# for i in "$@"; do echo "DEBUG: $i"; done;
|
||||
# echo "DEBUG: sync_dir_sym: ${sync_dir_sym}"
|
||||
# echo "DEBUG: sync_dir: ${sync_dir}"
|
||||
# echo "DEBUG: cwd: ${cwd}"
|
||||
# echo "DEBUG: callback: ${callback}"
|
||||
# echo
|
||||
|
||||
# remove the first element (the callback) from $@
|
||||
# https://stackoverflow.com/questions/2701400/remove-first-element-from-in-bash
|
||||
shift
|
||||
|
||||
|
||||
# loop through all files received as an parameter array
|
||||
indexA=0
|
||||
for input_file in "${@}"; do
|
||||
indexA=$((indexA+1))
|
||||
# echo "- - - - - - - - - -"
|
||||
# echo "DEBUG [indexA]: ${indexA}"
|
||||
# echo "DEBUG [\$@]: $@"
|
||||
# echo "DEBUG [input_file]: ${input_file[@]}"
|
||||
|
||||
# lf file manager sends multiple files as one input parameter, split by with newlines
|
||||
# https://superuser.com/questions/284187/bash-iterating-over-lines-in-a-variable
|
||||
declare -a theArray
|
||||
# reset array | https://stackoverflow.com/questions/28737493/resetting-an-array-and-filling-it-with-values-in-a-bash-script
|
||||
theArray=()
|
||||
while read -r arrayLine
|
||||
do
|
||||
theArray+=("$arrayLine")
|
||||
done <<< "$input_file"
|
||||
|
||||
# echo "DEBUG [theArray]: ${theArray[@]}"
|
||||
|
||||
indexB=0
|
||||
for line in "${theArray[@]}"
|
||||
do
|
||||
indexB=$((indexB+1))
|
||||
# echo " DEBUG [indexB]: ${indexB}"
|
||||
# echo " DEBUG [line]: ${line}"
|
||||
|
||||
# if input file has no path specified
|
||||
if [[ ${line} != *"/"* ]]; then
|
||||
line="${cwd}/${line}"
|
||||
fi
|
||||
|
||||
# substitute parts of the old path, from using the symlink folder, to the non-symlink folder
|
||||
# example:
|
||||
# "/home/poq/syncDir/0_downloads/topBanner.jpg" > "/home/poq/nextcloud/syncDir/0_downloads/topBanner.jpg"
|
||||
# new_file=${original_string//old_substring/new_substring}
|
||||
new_file=${line//$sync_dir_sym/$sync_dir}
|
||||
|
||||
if [[ -f "${new_file}" ]] || [[ -d "${new_file}" ]] ; then
|
||||
echo "${callback} ${new_file}"
|
||||
${callback} "${new_file}"
|
||||
else
|
||||
echo "ERROR: file not found: \"${new_file}\""
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
done
|
||||
150
dots/bin/obsolete/obsolete.lordOfTheRing.sh
Normal file
150
dots/bin/obsolete/obsolete.lordOfTheRing.sh
Normal file
@@ -0,0 +1,150 @@
|
||||
# frode klevstul : start 24.11.16 : add data to keyring
|
||||
|
||||
# ---------- info and how-to update ----------
|
||||
|
||||
# this script was made after experiencing that my keyrings was getting lost after upgrades.
|
||||
# the stored passwords here have to be updated now and then. to do that, deleting
|
||||
# existing keyring (using seahorse), and re-login to the system. then use seahorse to see
|
||||
# what values are being stored. those values are then to be copied over to this script (further below).
|
||||
|
||||
# ---------- nifty info
|
||||
|
||||
# Store secret:
|
||||
# SECRET="12345678"
|
||||
# echo -n "${SECRET}" \
|
||||
# | secret-tool store --label="Secret for example.org" domain example.org
|
||||
#
|
||||
# Lookup secret:
|
||||
# SECRET="$(secret-tool lookup domain example.org)"
|
||||
# echo "${SECRET}"
|
||||
#
|
||||
# src: https://discourse.gnome.org/t/how-do-you-actually-use-secret-tool/19818/2
|
||||
|
||||
# the key ring files are automatically stored at:
|
||||
# ~/.local/share/keyrings/login.keyring
|
||||
|
||||
|
||||
# locate the first keyring file in the keyring directory
|
||||
keyring_dir=/home/poq/.local/share/keyrings
|
||||
keyring_file=""
|
||||
for entry in "${keyring_dir}"/*
|
||||
do
|
||||
if [[ ${entry} == *.keyring ]] ; then
|
||||
echo "found keyring file: ${entry}"
|
||||
keyring_file=${entry}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${keyring_file} == "" ]] ; then
|
||||
echo "no keyring file found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# due to some scope issue, that i did not figure out how to solve, i am using tmp files on the os to keep track of stuff.
|
||||
# this instead of using variables, which would be the normal thing to do
|
||||
|
||||
# 'tf' for temporary file
|
||||
tf_secret_to_get="/tmp/stg.lotr"
|
||||
tf_secret_nextcloud="/tmp/sn.lotr"
|
||||
tf_secret_nextcloud_app="/tmp/sna.lotr"
|
||||
tf_secret_nextcloud_base="/tmp/snb.lotr"
|
||||
tf_secret_proton_account_singular="/tmp/sps.lotr"
|
||||
tf_secret_proton_accounts_multiple="/tmp/spm.lotr"
|
||||
tf_log_population_nextcloud="/tmp/lotr_nextcloud_populated.lotr"
|
||||
tf_log_population_proton="/tmp/lotr_nextcloud_populated.lotr"
|
||||
|
||||
# https://gist.github.com/melbahja/33fac6f3f823632e880401f5f7451cfb
|
||||
cat ${keyring_file} | while read line || [[ -n ${line} ]];
|
||||
do
|
||||
[[ ${line//[[:space:]]/} =~ ^#.* || -z "$line" ]] && continue
|
||||
echo $line | tr "=" "\n" | while read -r key; do
|
||||
read -r value
|
||||
if [[ ${value} != "" ]] ; then
|
||||
if [[ ${key} == "display-name" ]] ; then
|
||||
if [[ ${value} == "Nextcloud" ]] ; then
|
||||
echo "get nextcloud value";
|
||||
echo "nextcloud" > ${tf_secret_to_get}
|
||||
elif [[ ${value} =~ "Proton" ]] && [[ ${value} =~ "proton-sso-account-" ]] ; then
|
||||
echo "get proton 'account' (singular) value";
|
||||
echo "proton_account_singular" > ${tf_secret_to_get};
|
||||
elif [[ ${value} =~ "Proton" ]] && [[ ${value} =~ "proton-sso-accounts" ]] ; then
|
||||
echo "get proton 'accounts' (multiple) value";
|
||||
echo "proton_account_multiple" > ${tf_secret_to_get};
|
||||
fi
|
||||
elif [[ ${key} == "secret" ]] ; then
|
||||
secret_to_get=$(cat ${tf_secret_to_get});
|
||||
echo "secret found for ${secret_to_get}";
|
||||
|
||||
if [[ ${secret_to_get} == "nextcloud" ]] ; then
|
||||
echo ${value} > ${tf_secret_nextcloud};
|
||||
elif [[ ${secret_to_get} == "proton_account_singular" ]] ; then
|
||||
echo "storing proton account singular value"
|
||||
# this is a multi-line value, so we need to do some more trickery, to get it working…
|
||||
# https://www.baeldung.com/linux/print-lines-between-two-patterns
|
||||
# https://unix.stackexchange.com/questions/471619/get-everything-after-first-occurence-of-substring
|
||||
value=$(awk '/secret={"UID":/{ f = 1 } /mtime=/{ f = 0 } f' ${keyring_file} | perl -pe 's/.*?secret=//');
|
||||
echo ${value} > ${tf_secret_proton_account_singular};
|
||||
elif [[ ${secret_to_get} == "proton_account_multiple" ]] ; then
|
||||
echo "storing proton multiple value"
|
||||
echo ${value} > ${tf_secret_proton_accounts_multiple};
|
||||
else
|
||||
echo "can not handle the secret_to_get value: '${secret_to_get}'";
|
||||
fi
|
||||
elif [[ ${value} =~ "_app-password:https://nx.op.fo" ]] ; then
|
||||
echo "storing nextcloud app secret"
|
||||
value=$(cat ${tf_secret_nextcloud});
|
||||
echo ${value} > ${tf_secret_nextcloud_app};
|
||||
elif [[ ${value} =~ ":https://nx.op.fo" ]] ; then
|
||||
echo "storing nextcloud base secret"
|
||||
value=$(cat ${tf_secret_nextcloud});
|
||||
echo ${value} > ${tf_secret_nextcloud_base};
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# --------------------
|
||||
# NEXTCLOUD
|
||||
# --------------------
|
||||
|
||||
hasNextcloud=$(secret-tool lookup server Nextcloud)
|
||||
|
||||
if [[ -z "${hasNextcloud}" ]]
|
||||
then
|
||||
echo "adding keys for nextcloud"
|
||||
|
||||
# >>> set value 1 | frode_app-password:https://nx.op.fo/:0
|
||||
pwd_user_frode_app=$(cat ${tf_secret_nextcloud_app});
|
||||
echo -n "${pwd_user_frode_app}" | secret-tool store --label="Nextcloud" server Nextcloud user frode_app-password:https://nx.op.fo/:0 type base64
|
||||
|
||||
# >>> set value 2 | frode:https://nx.op.fo/:0
|
||||
pwd_user_frode=$(cat ${tf_secret_nextcloud_base});
|
||||
echo -n "${pwd_user_frode}" | secret-tool store --label="Nextcloud" server Nextcloud user frode:https://nx.op.fo/:0 type plaintext
|
||||
|
||||
echo "OK" > ${tf_log_population_nextcloud};
|
||||
fi
|
||||
|
||||
# --------------------
|
||||
# PROTONVPN
|
||||
# --------------------
|
||||
|
||||
hasProtonVpn=$(secret-tool lookup service Proton)
|
||||
|
||||
if [[ -z "${hasProtonVpn}" ]]
|
||||
then
|
||||
echo "adding keys for protonvpn"
|
||||
|
||||
# >>> set value 1 | proton-sso-account-mzzg6zdf
|
||||
# note: It is significant that the last closing parenthesis is on another line, and END text must also appear on a line by itself.
|
||||
# And, there can be no indent on this line, or no spaces/tabs at the beginning of the line.
|
||||
# ref: https://stackoverflow.com/questions/23929235/multi-line-string-with-extra-space-preserved-indentation
|
||||
pwd_proton_1=$(cat ${tf_secret_proton_account_singular});
|
||||
echo -n "${pwd_proton_1}" | secret-tool store --label="Password for 'proton-sso-account-mzzg6zdf' on 'Proton'" application "Python keyring library" service Proton username proton-sso-account-mzzg6zdf
|
||||
|
||||
# >>> set value 2 | proton-sso-accounts
|
||||
pwd_proton_2=$(cat ${tf_secret_proton_accounts_multiple});
|
||||
echo -n "${pwd_proton_2}" | secret-tool store --label="Password for 'proton-sso-accounts' on 'Proton'" application "Python keyring library" service Proton username proton-sso-accounts
|
||||
|
||||
echo "OK" > ${tf_log_population_proton};
|
||||
fi
|
||||
42
dots/bin/obsolete/obsolete.pCloudSynologyDriveRestarter.sh
Normal file
42
dots/bin/obsolete/obsolete.pCloudSynologyDriveRestarter.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# frode klevstul : start 25.05.11 : restart pcloud and synology-drive, as pcloud issues hinder continous syncing
|
||||
|
||||
# 900 sec = 15 minutes
|
||||
secs=900
|
||||
|
||||
while true
|
||||
do
|
||||
|
||||
if pidof cloud-drive-ui ; then
|
||||
echo "kill synology-drive"
|
||||
# pkill: pattern that searches for process name longer than 15 characters will result in zero matches, so:
|
||||
pidof cloud-drive-connect | xargs kill -15
|
||||
pkill -15 cloud-drive-ui
|
||||
sleep 10
|
||||
else
|
||||
echo "Synology-Drive is not running, so no killing is neccessary (this time around…)"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if pidof pcloud ; then
|
||||
echo "kill pcloud"
|
||||
pkill -15 pcloud
|
||||
sleep 10
|
||||
else
|
||||
echo "pCloud is not running, so no killing is neccessary (this time around…)"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
echo "start pCloud"
|
||||
pcloud &
|
||||
sleep 5
|
||||
|
||||
echo "start Synology-Drive"
|
||||
synology-drive &
|
||||
sleep 5
|
||||
|
||||
echo "sleep for ${secs} seconds, wake up, repeat (ctrl+c to stop)"
|
||||
sleep ${secs}
|
||||
|
||||
done
|
||||
Reference in New Issue
Block a user