This commit is contained in:
Ray Elliott 2020-08-09 13:53:06 +01:00
parent 4b42aa2fce
commit e4b7f615fa
33 changed files with 543 additions and 0 deletions

1
archnews Symbolic link
View File

@ -0,0 +1 @@
/home/ray/.src/archnews/archnews

1
barrier_run Symbolic link
View File

@ -0,0 +1 @@
/home/ray/.config/barrier/run_barrier.sh

1
bashtop Symbolic link
View File

@ -0,0 +1 @@
/usr/local/src/bashtop/bashtop

2
colors-show Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
for x in 0 1 4 5 7 8; do for i in `seq 30 37`; do for a in `seq 40 47`; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo "";

8
dmenu_power Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
OPTIONS="suspend\npoweroff\nreboot"
. ~/.dmenurc
dmenu_cmd="dmenu $DMENU_OPTIONS"
result=$(printf "$OPTIONS" | $dmenu_cmd -i -p 'systemctl ')
systemctl "$result"

100
dmenu_recency Executable file
View File

@ -0,0 +1,100 @@
#!/bin/bash
# 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"
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"

39
dmenu_ssh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
. ~/.dmenurc
dmenu_cmd="dmenu $DMENU_OPTIONS"
HOSTS="alarmPi\nb1.isnet.uk\ndocker666\nHetzner\nhmb.isnet.uk\nkvm.isnet.uk\nmac\nProxmox\ns1.isnet.uk\n"
RESULT=$(printf "$HOSTS" | $dmenu_cmd -i -p "Host:")
case $RESULT in
alarmPi)
st ssh 192.168.0.11
;;
b1.isnet.uk)
st ssh -p666 ray@b1.isnet.uk -t tmux
;;
docker666)
st ssh ray@192.168.0.101 -t tmux
;;
Hetzner)
st ssh ray@116.203.63.174
;;
hmb.isnet.uk)
st ssh -p666 ray@hmb.isnet.uk -t tmux
;;
kvm.isnet.uk)
st ssh -p666 ray@kvm.isnet.uk -t tmux
;;
mac)
st ssh ray@mac -t tmux
;;
Proxmox)
st ssh ray@192.168.0.99 -t tmux
;;
s1.isnet.uk)
st ssh -p666 ray@s1.isnet.uk -t tmux
;;
esac

3
fontlist Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
fc-list | cut -f2 -d: | sort -u | less -r

43
get-xprop Executable file
View File

@ -0,0 +1,43 @@
#!/bin/sh
# https://faq.i3wm.org/question/2172/how-do-i-find-the-criteria-for-use-with-i3-config-commands-like-for_window-eg-to-force-splashscreens-and-dialogs-to-show-in-floating-mode.1.html
# i3-get-window-criteria - Get criteria for use with i3 config commands
# To use, run this script, then click on a window.
# Output is in the format: [<name>=<value> <name>=<value> ...]
# Known problem: when WM_NAME is used as fallback for the 'title="<string>"' criterion,
# quotes in "<string>" are not escaped properly. This is a problem with the output of `xprop`,
# reported upstream: https://bugs.freedesktop.org/show_bug.cgi?id=66807
PROGNAME=`basename "$0"`
# Check for xwininfo and xprop
for cmd in xwininfo xprop; do
if ! which $cmd > /dev/null 2>&1; then
echo "$PROGNAME: $cmd: command not found" >&2
exit 1
fi
done
match_int='[0-9][0-9]*'
match_string='".*"'
match_qstring='"[^"\\]*(\\.[^"\\]*)*"' # NOTE: Adds 1 backreference
{
# Run xwininfo, get window id
window_id=`xwininfo -int | sed -nre "s/^xwininfo: Window id: ($match_int) .*$/\1/p"`
echo "id=$window_id"
# Run xprop, transform its output into i3 criteria. Handle fallback to
# WM_NAME when _NET_WM_NAME isn't set
xprop -id $window_id |
sed -nr \
-e "s/^WM_CLASS\(STRING\) = ($match_qstring), ($match_qstring)$/instance=\1\nclass=\3/p" \
-e "s/^WM_WINDOW_ROLE\(STRING\) = ($match_qstring)$/window_role=\1/p" \
-e "/^WM_NAME\(STRING\) = ($match_string)$/{s//title=\1/; h}" \
-e "/^_NET_WM_NAME\(UTF8_STRING\) = ($match_qstring)$/{s//title=\1/; h}" \
-e '${g; p}'
} | sort | tr "\n" " " | sed -r 's/^(.*) $/[\1]\n/'

31
git-change-port Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
new_port=$1
branch_name=$(git rev-parse --abbrev-ref HEAD)
remote_name=$(git remote -v | awk 'NR==1{print $1}')
remote_url_new=$(git remote -v | awk 'NR==1{print $2}' | sed 's/:[0-9]\{2,5\}\//:'"$new_port"'\//')
echo 'Remote:'
git remote -v
echo ""
echo "Setting new remote ..."
git remote remove "$remote_name"
git remote add "$remote_name" "$remote_url_new"
echo "New remote set."
echo ""
echo "Fetching ..."
git fetch
echo "Setting branch ..."
git branch "--set-upstream-to=$remote_name/$branch_name" "$branch_name"
echo ""
echo 'Remote:'
git remote -v
echo ""
echo "Branch:"
git branch -v
echo ""

80
i3-scrot Executable file
View File

@ -0,0 +1,80 @@
#!/bin/sh
# /usr/bin/i3-scrot
#
# simple screenshot-script using scrot for manjaro-i3 by oberon@manjaro.org
_conf=$HOME/.config/i3-scrot.conf
if ! [ -f $_conf ]; then
echo "scrot_dir=$(xdg-user-dir PICTURES)/Screens" > $_conf
fi
source $_conf
if ! [ -d $scrot_dir ]; then
mkdir -p $scrot_dir
fi
if ! [[ -z "$2" ]]; then
cmd="scrot -d $2"
else
cmd='scrot'
fi
case "$1" in
--window|-w|$NULL)
cd $scrot_dir
$cmd -u &&
sleep 1 &&
notify-send "screenshot has been saved in $scrot_dir"
;;
--desk|-d)
cd $scrot_dir
$cmd &&
sleep 1 &&
notify-send "screenshot has been saved in $scrot_dir"
;;
--select|-s)
cd $scrot_dir
notify-send 'select an area for the screenshot' &
scrot -s &&
sleep 1 && notify-send "screenshot has been saved in $scrot_dir"
;;
--help|-h)
echo "
available options:
-d | --desk full screen
-w | --window active window
-s | --select selection
-h | --help display this information
The -d or -w options can be used with a delay
by adding the number of seconds, like for example:
'i3-scrot -w 5'
Default option is 'window'.
The file destination can be set in ${_conf}.
Default is $scrot_dir
"
;;
*)
echo "
== ! i3-scrot: missing or wrong argument ! ==
available options:
-d | --desk full screen
-w | --window active window
-s | --select selection
-h | --help display this information
Default option is 'window'.
The file destination can be set in ${_conf}.
Default is $scrot_dir
"
exit 2
esac
exit 0

6
keycode-show Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# https://wiki.archlinux.org/index.php/Keyboard_input#Using_evtest
xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'

6
keycodes Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# https://wiki.archlinux.org/index.php/Keyboard_input#Using_evtest
xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'

BIN
lazygit Executable file

Binary file not shown.

7
mirrorlist-update Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
sudo curl -o /etc/pacman.d/mirrorlist https://www.archlinux.org/mirrorlist/all/
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
sudo reflector --verbose -c 'United Kingdom' -f 10 -l 50 --sort rate --save /etc/pacman.d/mirrorlist
echo "Update complete."

17
mirrors-update Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
echo "Downloading mirrorlist"
curl -o ~/Temp/mirrorlist.txt https://www.archlinux.org/mirrorlist/?country=FR&country=DE&country=GB&protocol=http&protocol=https&ip_version=4&use_mirror_status=on
sed -i 's/#S/S/g' ~/Temp/mirrorlist.txt
echo "Ranking mirrorlist"
rankmirrors ~/Temp/mirrorlist.txt > ~/Temp/mirrorlist-fastest.txt
echo "Backing up existing mirrorlist"
sudo mv -v /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.old
echo "Setting new mirrorlist"
sudo mv -v ~/Temp/mirrorlist-fastest.txt /etc/pacman.d/mirrorlist
echo "Updating repositories"
sudo pacman -Syyu

23
mogrify-resize Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
#!/bin/bash
width=$1
if [ -z "$width" ]
then
width=1920
fi
directory=resize-$width
mkdir $directory
# prevent empty directories from returning *.jpg in for loop
shopt -s nullglob
for ext in jpg jpeg png; do
for file in *."$ext"; do
echo resizing "$file";
mogrify -path $directory -filter Triangle -define filter:support=2 -thumbnail $width -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip "$file"
done
done

3
mpv-download Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
/home/ray/Projects/mpv-dl-trim/venv/bin/python /home/ray/Projects/mpv-dl-trim/mpv_dl_trim.py $@

109
pve-spice Executable file
View File

@ -0,0 +1,109 @@
#!/bin/bash
#
# SETTINGS
#
# Fill the following section with your prefered settings.
# Leaving the password field empty is much more secure. It will be prompted on the command line.
# Alternatively create a Proxmox user with limited privileges like shown in this template.
#
NODE="pve"
VMID="$1"
PROXY=""
USERNAME="root@pam"
PASSWORD="r3478eE3478"
#
# INITIALIZATION
#
if ! type "jq" > /dev/null; then
echo 'Command line tool "jq" is needed. Please install.'
fi
if [ -z "$PASSWORD" ]; then
read -s -p "Password: " PASSWORD
echo
fi
if [ -z "$USERNAME" ]; then
USERNAME=root@pam
fi
if [ -z "$PROXY" ]; then
PROXY=$NODE
fi
#
# AUTHENTICATION PROCESS
#
RESPONSE=$(curl -f -s -S -k -d "username=$USERNAME&password=$PASSWORD" "https://$PROXY:8006/api2/json/access/ticket")
if [ $? -ne 0 ]; then
echo "ERROR: Authentication failed"
exit 1
fi
TICKET=$(echo $RESPONSE | jq -r '.data.ticket')
CSRF=$(echo $RESPONSE | jq -r '.data.CSRFPreventionToken')
if [ -z "$TICKET" ] || [ -z "$CSRF" ]; then
echo "ERROR: Could not process Authentication Ticket"
exit 1
fi
#
# GET SPICE CONFIGURATION
#
RESPONSE=$(curl -f -s -S -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" "https://$PROXY:8006/api2/json/nodes/$NODE/qemu/$VMID/spiceproxy" -d "proxy=$PROXY")
if [ $? -ne 0 ]; then
echo "ERROR: Maybe Proxmox-API changed?"
exit 1
fi
#
# PARSING JSON RESPONSE
#
ATTENTION=$(echo $RESPONSE | jq -r '.data."secure-attention"')
DELETE=$(echo $RESPONSE | jq -r '.data."delete-this-file"')
PROXY=$(echo $RESPONSE | jq -r '.data.proxy')
TYPE=$(echo $RESPONSE | jq -r '.data.type')
CA=$(echo $RESPONSE | jq -r '.data.ca')
FULLSCREEN=$(echo $RESPONSE | jq -r '.data."toggle-fullscreen"')
TITLE=$(echo $RESPONSE | jq -r '.data.title')
HOST=$(echo $RESPONSE | jq -r '.data.host')
PASSWORD=$(echo $RESPONSE | jq -r '.data.password')
SUBJECT=$(echo $RESPONSE | jq -r '.data."host-subject"')
CURSOR=$(echo $RESPONSE | jq -r '.data."release-cursor"')
PORT=$(echo $RESPONSE | jq -r '.data."tls-port"')
#
# GENERATING REMOTE-VIEWER CONNECTION FILE
#
TMP=$(mktemp)
echo "[virt-viewer]" > $TMP
echo "secure-attention=${ATTENTION}" >> $TMP
echo "delete-this-file=${DELETE}" >> $TMP
echo "proxy=${PROXY}" >> $TMP
echo "type=${TYPE}" >> $TMP
echo "ca=${CA}" >> $TMP
echo "toggle-fullscreen=${FULLSCREEN}" >> $TMP
echo "title=${TITLE}" >> $TMP
echo "host=${HOST}" >> $TMP
echo "password=${PASSWORD}" >> $TMP
echo "host-subject=${SUBJECT}" >> $TMP
echo "release-cursor=${CURSOR}" >> $TMP
echo "tls-port=${PORT}" >> $TMP
#
# STARTING REMOTE-VIEWER
#
remote-viewer -f $TMP &

3
qutex Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
qutebrowser -B ~/.config/qutebrowser2/ &

3
qutey Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
qutebrowser -B ~/.config/qutebrowser3/ &

2
sbio Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
ncftp -u psb18896 ftp://psb18896.seedbox.io/files

2
sbss Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
ncftp -u 04ujk -P 5757 ftp://37.187.147.24/torrents/rtorrent/

9
smartdnotify Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
#notify user
sudo -u ray DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send -u critical "$SMARTD_MESSAGE"
#send email
echo "$SMARTD_MESSAGE" | su ray -c "neomutt -s \"$SMARTD_FAILTYPE\" \"$SMARTD_ADDRESS\""
# vim: set filetype=sh:

BIN
starship Executable file

Binary file not shown.

38
vimv Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# Lists the current directory's files in Vim, so you can edit it and save to rename them
# USAGE: vimv [file1 file2]
# https://github.com/thameera/vimv
declare -r FILENAMES_FILE="$(mktemp --tmpdir vimv.XXX)"
trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT
if [ $# -ne 0 ]; then
src=( "$@" )
else
IFS=$'\r\n' GLOBIGNORE='*' command eval 'src=($(ls))'
fi
for ((i=0;i<${#src[@]};++i)); do
echo "${src[i]}" >> "${FILENAMES_FILE}"
done
${EDITOR:-vi} "${FILENAMES_FILE}"
IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))'
count=0
for ((i=0;i<${#src[@]};++i)); do
if [ "${src[i]}" != "${dest[i]}" ]; then
mkdir -p "`dirname "${dest[i]}"`"
if git ls-files --error-unmatch "${src[i]}" > /dev/null 2>&1; then
git mv "${src[i]}" "${dest[i]}"
else
mv "${src[i]}" "${dest[i]}"
fi
((count++))
fi
done
echo "$count" files renamed.

1
wp-dev Symbolic link
View File

@ -0,0 +1 @@
/home/ray/Projects/wordpress-dev/list-commands.sh

1
wp-dev-container Symbolic link
View File

@ -0,0 +1 @@
/home/ray/Projects/wordpress-dev/container-setup.sh

1
wp-dev-create Symbolic link
View File

@ -0,0 +1 @@
/home/ray/Projects/wordpress-dev/create-config.sh

1
wp-dev-publish Symbolic link
View File

@ -0,0 +1 @@
/home/ray/Projects/wordpress-dev/publish.sh

1
wp-dev-testdata Symbolic link
View File

@ -0,0 +1 @@
/home/ray/Projects/wordpress-dev/import-testdata.sh

1
wp-dev-webserver Symbolic link
View File

@ -0,0 +1 @@
/home/ray/Projects/wordpress-dev/webserver-provision.sh