diff --git a/GIT_README.txt b/README.md similarity index 100% rename from GIT_README.txt rename to README.md diff --git a/archnews b/archnews new file mode 120000 index 0000000..c5fc240 --- /dev/null +++ b/archnews @@ -0,0 +1 @@ +/home/ray/.src/archnews/archnews \ No newline at end of file diff --git a/barrier_run b/barrier_run new file mode 120000 index 0000000..1d7bd4d --- /dev/null +++ b/barrier_run @@ -0,0 +1 @@ +/home/ray/.config/barrier/run_barrier.sh \ No newline at end of file diff --git a/bashtop b/bashtop new file mode 120000 index 0000000..df746cf --- /dev/null +++ b/bashtop @@ -0,0 +1 @@ +/usr/local/src/bashtop/bashtop \ No newline at end of file diff --git a/colors-show b/colors-show new file mode 100755 index 0000000..e830ed9 --- /dev/null +++ b/colors-show @@ -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 ""; diff --git a/dmenu_power b/dmenu_power new file mode 100755 index 0000000..edd45de --- /dev/null +++ b/dmenu_power @@ -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" diff --git a/dmenu_recency b/dmenu_recency new file mode 100755 index 0000000..6cc72cd --- /dev/null +++ b/dmenu_recency @@ -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" diff --git a/dmenu_ssh b/dmenu_ssh new file mode 100755 index 0000000..fbbdf70 --- /dev/null +++ b/dmenu_ssh @@ -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 + diff --git a/fontlist b/fontlist new file mode 100755 index 0000000..7d4d857 --- /dev/null +++ b/fontlist @@ -0,0 +1,3 @@ +#!/bin/bash + +fc-list | cut -f2 -d: | sort -u | less -r diff --git a/get-xprop b/get-xprop new file mode 100755 index 0000000..b2aa612 --- /dev/null +++ b/get-xprop @@ -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: [= = ...] + +# Known problem: when WM_NAME is used as fallback for the 'title=""' criterion, +# quotes in "" 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/' diff --git a/git-change-port b/git-change-port new file mode 100755 index 0000000..f41e220 --- /dev/null +++ b/git-change-port @@ -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 "" diff --git a/i3-scrot b/i3-scrot new file mode 100755 index 0000000..620bc9d --- /dev/null +++ b/i3-scrot @@ -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 diff --git a/keycode-show b/keycode-show new file mode 100755 index 0000000..80babb7 --- /dev/null +++ b/keycode-show @@ -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 }' + diff --git a/keycodes b/keycodes new file mode 100755 index 0000000..80babb7 --- /dev/null +++ b/keycodes @@ -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 }' + diff --git a/lazygit b/lazygit new file mode 100755 index 0000000..fd0b76b Binary files /dev/null and b/lazygit differ diff --git a/mirrorlist-update b/mirrorlist-update new file mode 100755 index 0000000..2eac2b8 --- /dev/null +++ b/mirrorlist-update @@ -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." diff --git a/mirrors-update b/mirrors-update new file mode 100755 index 0000000..b2aee2e --- /dev/null +++ b/mirrors-update @@ -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 diff --git a/mogrify-resize b/mogrify-resize new file mode 100755 index 0000000..14a2e8c --- /dev/null +++ b/mogrify-resize @@ -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 + diff --git a/mpv-download b/mpv-download new file mode 100755 index 0000000..7f59b4f --- /dev/null +++ b/mpv-download @@ -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 $@ diff --git a/pve-spice b/pve-spice new file mode 100755 index 0000000..0b444ee --- /dev/null +++ b/pve-spice @@ -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 & diff --git a/qutex b/qutex new file mode 100755 index 0000000..4ddd99a --- /dev/null +++ b/qutex @@ -0,0 +1,3 @@ +#!/bin/sh + +qutebrowser -B ~/.config/qutebrowser2/ & diff --git a/qutey b/qutey new file mode 100755 index 0000000..d960a0c --- /dev/null +++ b/qutey @@ -0,0 +1,3 @@ +#!/bin/sh + +qutebrowser -B ~/.config/qutebrowser3/ & diff --git a/sbio b/sbio new file mode 100755 index 0000000..12cc432 --- /dev/null +++ b/sbio @@ -0,0 +1,2 @@ +#!/bin/bash +ncftp -u psb18896 ftp://psb18896.seedbox.io/files diff --git a/sbss b/sbss new file mode 100755 index 0000000..5f638c8 --- /dev/null +++ b/sbss @@ -0,0 +1,2 @@ +#!/bin/bash +ncftp -u 04ujk -P 5757 ftp://37.187.147.24/torrents/rtorrent/ diff --git a/smartdnotify b/smartdnotify new file mode 100755 index 0000000..637ab64 --- /dev/null +++ b/smartdnotify @@ -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: diff --git a/starship b/starship new file mode 100755 index 0000000..9d633fa Binary files /dev/null and b/starship differ diff --git a/vimv b/vimv new file mode 100755 index 0000000..3c78afb --- /dev/null +++ b/vimv @@ -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. diff --git a/wp-dev b/wp-dev new file mode 120000 index 0000000..ad2df87 --- /dev/null +++ b/wp-dev @@ -0,0 +1 @@ +/home/ray/Projects/wordpress-dev/list-commands.sh \ No newline at end of file diff --git a/wp-dev-container b/wp-dev-container new file mode 120000 index 0000000..476d50d --- /dev/null +++ b/wp-dev-container @@ -0,0 +1 @@ +/home/ray/Projects/wordpress-dev/container-setup.sh \ No newline at end of file diff --git a/wp-dev-create b/wp-dev-create new file mode 120000 index 0000000..8b74ee6 --- /dev/null +++ b/wp-dev-create @@ -0,0 +1 @@ +/home/ray/Projects/wordpress-dev/create-config.sh \ No newline at end of file diff --git a/wp-dev-publish b/wp-dev-publish new file mode 120000 index 0000000..9f9df55 --- /dev/null +++ b/wp-dev-publish @@ -0,0 +1 @@ +/home/ray/Projects/wordpress-dev/publish.sh \ No newline at end of file diff --git a/wp-dev-testdata b/wp-dev-testdata new file mode 120000 index 0000000..5f554a9 --- /dev/null +++ b/wp-dev-testdata @@ -0,0 +1 @@ +/home/ray/Projects/wordpress-dev/import-testdata.sh \ No newline at end of file diff --git a/wp-dev-webserver b/wp-dev-webserver new file mode 120000 index 0000000..34714f1 --- /dev/null +++ b/wp-dev-webserver @@ -0,0 +1 @@ +/home/ray/Projects/wordpress-dev/webserver-provision.sh \ No newline at end of file