diff --git a/tools/README.md b/scripts/README.md similarity index 100% rename from tools/README.md rename to scripts/README.md diff --git a/tools/disable-ipv6.sh b/scripts/disable-ipv6.sh similarity index 100% rename from tools/disable-ipv6.sh rename to scripts/disable-ipv6.sh diff --git a/tools/display-resolution.sh b/scripts/display-resolution.sh similarity index 100% rename from tools/display-resolution.sh rename to scripts/display-resolution.sh diff --git a/tools/display-rotate.sh b/scripts/display-rotate.sh similarity index 75% rename from tools/display-rotate.sh rename to scripts/display-rotate.sh index f05c4f9..385e053 100755 --- a/tools/display-rotate.sh +++ b/scripts/display-rotate.sh @@ -6,6 +6,6 @@ # Wayland KDE: https://www.reddit.com/r/kde/comments/11vrbwc/how_do_i_rotate_the_screen_on_kde_with_wayland/ # kscreen-doctor --outputs -OUTPUT='HDMI-0' -DIRECTION="$1" # (left|right|normal|inverted) +OUTPUT='HDMI-A-1' +[ "$1" ] && DIRECTION="$1" || DIRECTION="normal" # (left|right|normal|inverted) kscreen-doctor "output.$OUTPUT.rotation.$DIRECTION" diff --git a/tools/docker-volume-snapshot.sh b/scripts/docker-volume-snapshot.sh similarity index 100% rename from tools/docker-volume-snapshot.sh rename to scripts/docker-volume-snapshot.sh diff --git a/tools/duckdns/.env.example b/scripts/duckdns/.env.example similarity index 100% rename from tools/duckdns/.env.example rename to scripts/duckdns/.env.example diff --git a/tools/duckdns/.gitignore b/scripts/duckdns/.gitignore similarity index 100% rename from tools/duckdns/.gitignore rename to scripts/duckdns/.gitignore diff --git a/tools/duckdns/install.sh b/scripts/duckdns/install.sh similarity index 100% rename from tools/duckdns/install.sh rename to scripts/duckdns/install.sh diff --git a/tools/duckdns/uninstall.sh b/scripts/duckdns/uninstall.sh similarity index 100% rename from tools/duckdns/uninstall.sh rename to scripts/duckdns/uninstall.sh diff --git a/tools/duckdns/update.sh b/scripts/duckdns/update.sh similarity index 100% rename from tools/duckdns/update.sh rename to scripts/duckdns/update.sh diff --git a/tools/fix-obs-vcam.sh b/scripts/fix-obs-vcam.sh similarity index 100% rename from tools/fix-obs-vcam.sh rename to scripts/fix-obs-vcam.sh diff --git a/tools/fix-repo-vivaldi.sh b/scripts/fix-repo-vivaldi.sh similarity index 100% rename from tools/fix-repo-vivaldi.sh rename to scripts/fix-repo-vivaldi.sh diff --git a/tools/fix-repo-vscode.sh b/scripts/fix-repo-vscode.sh similarity index 100% rename from tools/fix-repo-vscode.sh rename to scripts/fix-repo-vscode.sh diff --git a/tools/free-space.sh b/scripts/free-space.sh similarity index 100% rename from tools/free-space.sh rename to scripts/free-space.sh diff --git a/tools/frkn.sh b/scripts/frkn.sh similarity index 100% rename from tools/frkn.sh rename to scripts/frkn.sh diff --git a/helpers/arg-parser/README.md b/scripts/helpers/arg-parser/README.md similarity index 100% rename from helpers/arg-parser/README.md rename to scripts/helpers/arg-parser/README.md diff --git a/helpers/arg-parser/args.sh b/scripts/helpers/arg-parser/args.sh similarity index 100% rename from helpers/arg-parser/args.sh rename to scripts/helpers/arg-parser/args.sh diff --git a/helpers/basic.sh b/scripts/helpers/basic.sh similarity index 100% rename from helpers/basic.sh rename to scripts/helpers/basic.sh diff --git a/helpers/debug.sh b/scripts/helpers/debug.sh similarity index 100% rename from helpers/debug.sh rename to scripts/helpers/debug.sh diff --git a/helpers/docker.sh b/scripts/helpers/docker.sh similarity index 100% rename from helpers/docker.sh rename to scripts/helpers/docker.sh diff --git a/helpers/git.sh b/scripts/helpers/git.sh similarity index 100% rename from helpers/git.sh rename to scripts/helpers/git.sh diff --git a/helpers/help.sh b/scripts/helpers/help.sh similarity index 100% rename from helpers/help.sh rename to scripts/helpers/help.sh diff --git a/helpers/io.sh b/scripts/helpers/io.sh similarity index 100% rename from helpers/io.sh rename to scripts/helpers/io.sh diff --git a/helpers/log.sh b/scripts/helpers/log.sh similarity index 100% rename from helpers/log.sh rename to scripts/helpers/log.sh diff --git a/helpers/misc.sh b/scripts/helpers/misc.sh similarity index 100% rename from helpers/misc.sh rename to scripts/helpers/misc.sh diff --git a/helpers/net.sh b/scripts/helpers/net.sh similarity index 100% rename from helpers/net.sh rename to scripts/helpers/net.sh diff --git a/helpers/notif.sh b/scripts/helpers/notif.sh similarity index 100% rename from helpers/notif.sh rename to scripts/helpers/notif.sh diff --git a/helpers/notifications.sh b/scripts/helpers/notifications.sh similarity index 100% rename from helpers/notifications.sh rename to scripts/helpers/notifications.sh diff --git a/helpers/packages.sh b/scripts/helpers/packages.sh similarity index 100% rename from helpers/packages.sh rename to scripts/helpers/packages.sh diff --git a/helpers/testing.sh b/scripts/helpers/testing.sh similarity index 100% rename from helpers/testing.sh rename to scripts/helpers/testing.sh diff --git a/helpers/traps.sh b/scripts/helpers/traps.sh similarity index 100% rename from helpers/traps.sh rename to scripts/helpers/traps.sh diff --git a/tools/ignore-veth.sh b/scripts/ignore-veth.sh similarity index 100% rename from tools/ignore-veth.sh rename to scripts/ignore-veth.sh diff --git a/tools/inotifywait-cp.sh b/scripts/inotifywait-cp.sh similarity index 100% rename from tools/inotifywait-cp.sh rename to scripts/inotifywait-cp.sh diff --git a/tools/inotifywait-cp/README.md b/scripts/inotifywait-cp/README.md similarity index 100% rename from tools/inotifywait-cp/README.md rename to scripts/inotifywait-cp/README.md diff --git a/tools/inotifywait-cp/inotifywait-cp.service b/scripts/inotifywait-cp/inotifywait-cp.service similarity index 100% rename from tools/inotifywait-cp/inotifywait-cp.service rename to scripts/inotifywait-cp/inotifywait-cp.service diff --git a/tools/inotifywait-cp/inotifywait-cp.sh b/scripts/inotifywait-cp/inotifywait-cp.sh similarity index 100% rename from tools/inotifywait-cp/inotifywait-cp.sh rename to scripts/inotifywait-cp/inotifywait-cp.sh diff --git a/tools/make-swapfile.sh b/scripts/make-swapfile.sh similarity index 100% rename from tools/make-swapfile.sh rename to scripts/make-swapfile.sh diff --git a/tools/netbeans-php-wrapper/php b/scripts/netbeans-php-wrapper/php similarity index 100% rename from tools/netbeans-php-wrapper/php rename to scripts/netbeans-php-wrapper/php diff --git a/tools/quick-backup.sh b/scripts/quick-backup.sh similarity index 100% rename from tools/quick-backup.sh rename to scripts/quick-backup.sh diff --git a/tools/rsync-backup.sh b/scripts/rsync-backup.sh similarity index 100% rename from tools/rsync-backup.sh rename to scripts/rsync-backup.sh diff --git a/tools/rutracker.sh b/scripts/rutracker.sh similarity index 100% rename from tools/rutracker.sh rename to scripts/rutracker.sh diff --git a/tools/s3-backup-old.sh b/scripts/s3-backup-old.sh similarity index 100% rename from tools/s3-backup-old.sh rename to scripts/s3-backup-old.sh diff --git a/tools/s3-backup.sh b/scripts/s3-backup.sh similarity index 100% rename from tools/s3-backup.sh rename to scripts/s3-backup.sh diff --git a/tools/setup-wakeonlan.sh b/scripts/setup-wakeonlan.sh similarity index 100% rename from tools/setup-wakeonlan.sh rename to scripts/setup-wakeonlan.sh diff --git a/tools/ubuntu/desktop-upgrade.sh b/scripts/ubuntu/desktop-upgrade.sh similarity index 100% rename from tools/ubuntu/desktop-upgrade.sh rename to scripts/ubuntu/desktop-upgrade.sh diff --git a/tools/ubuntu/lemp.sh b/scripts/ubuntu/lemp.sh similarity index 100% rename from tools/ubuntu/lemp.sh rename to scripts/ubuntu/lemp.sh diff --git a/tools/ubuntu/mediasrv.sh b/scripts/ubuntu/mediasrv.sh similarity index 100% rename from tools/ubuntu/mediasrv.sh rename to scripts/ubuntu/mediasrv.sh diff --git a/tools/ubuntu/server.sh b/scripts/ubuntu/server.sh similarity index 100% rename from tools/ubuntu/server.sh rename to scripts/ubuntu/server.sh diff --git a/scripts/utils/clock b/scripts/utils/clock new file mode 100755 index 0000000..861bce2 --- /dev/null +++ b/scripts/utils/clock @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +exec watch -tn 1 date '+%l:%M:%S%p' diff --git a/scripts/utils/copy b/scripts/utils/copy new file mode 100755 index 0000000..fde9f51 --- /dev/null +++ b/scripts/utils/copy @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e +set -u + +if hash pbcopy 2>/dev/null; then + exec pbcopy +elif hash xclip 2>/dev/null; then + exec xclip -selection clipboard +elif hash putclip 2>/dev/null; then + exec putclip +else + rm -f /tmp/clipboard 2> /dev/null + if [ $# -eq 0 ]; then + cat > /tmp/clipboard + else + cat "$1" > /tmp/clipboard + fi +fi diff --git a/tools/dc b/scripts/utils/dc old mode 100644 new mode 100755 similarity index 100% rename from tools/dc rename to scripts/utils/dc diff --git a/scripts/utils/httpcode b/scripts/utils/httpcode new file mode 100755 index 0000000..ca8cbd2 --- /dev/null +++ b/scripts/utils/httpcode @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -e +set -u + +statuses="100 Continue +101 Switching Protocols +102 Processing +200 OK +201 Created +202 Accepted +203 Non-Authoritative Information +204 No Content +205 Reset Content +206 Partial Content +207 Multi-Status +208 Already Reported +300 Multiple Choices +301 Moved Permanently +302 Found +303 See Other +304 Not Modified +305 Use Proxy +307 Temporary Redirect +400 Bad Request +401 Unauthorized +402 Payment Required +403 Forbidden +404 Not Found +405 Method Not Allowed +406 Not Acceptable +407 Proxy Authentication Required +408 Request Timeout +409 Conflict +410 Gone +411 Length Required +412 Precondition Failed +413 Request Entity Too Large +414 Request-URI Too Large +415 Unsupported Media Type +416 Request Range Not Satisfiable +417 Expectation Failed +418 I'm a teapot +420 Blaze it +422 Unprocessable Entity +423 Locked +424 Failed Dependency +425 No code +426 Upgrade Required +428 Precondition Required +429 Too Many Requests +431 Request Header Fields Too Large +449 Retry with +500 Internal Server Error +501 Not Implemented +502 Bad Gateway +503 Service Unavailable +504 Gateway Timeout +505 HTTP Version Not Supported +506 Variant Also Negotiates +507 Insufficient Storage +509 Bandwidth Limit Exceeded +510 Not Extended +511 Network Authentication Required" + +if [ $# -eq 0 ]; then + echo "$statuses" +else + echo "$statuses" | grep -i --color=never "$@" +fi diff --git a/scripts/utils/len b/scripts/utils/len new file mode 100755 index 0000000..46978e1 --- /dev/null +++ b/scripts/utils/len @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +set -u + +echo -n "$@" | wc -c | awk '{print $1}' diff --git a/scripts/utils/line b/scripts/utils/line new file mode 100755 index 0000000..e0da158 --- /dev/null +++ b/scripts/utils/line @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -e +set -u + +lineno="$1"; shift +sed -n "${lineno}p" -- "$@" diff --git a/scripts/utils/mksh b/scripts/utils/mksh new file mode 100755 index 0000000..37ade6a --- /dev/null +++ b/scripts/utils/mksh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +if [ ! $# -eq 1 ]; then + echo 'mksh takes one argument' 1>&2 + exit 1 +elif [ -e "$1" ]; then + echo "$1 already exists" 1>&2 + exit 1 +fi + +echo '#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +' > "$1" + +chmod u+x "$1" + +"$EDITOR" "$1" diff --git a/scripts/utils/note b/scripts/utils/note new file mode 100755 index 0000000..4609be4 --- /dev/null +++ b/scripts/utils/note @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# Note taking tool +# +# Usage: +# note [name] - Create a new note with optional name (defaults to "New note") +# note -e|--edit [name] - Edit an existing note by name +# +# Arguments explanation: +# [name] - Note filename (without extension) and title +# -e, --edit [name] - Edit existing note by name +# +# Detailed usage: +# note - Creates "New note" with current timestamp +# note my-idea - Creates note titled "my-idea" +# note my-idea "My Great Idea" - Creates note file "my-idea" but titled "My Great Idea" +# note -e my-idea - Edits existing note with name "my-idea" +# +# Notes are stored as markdown files in ~/notes/ with timestamps +# When multiple notes have the same name, you'll be prompted to select which one to edit + +arg1="$1" +arg2="$2" +path="$HOME/notes" +[[ ! -d "$path" ]] && mkdir -p "$path" + +shopt -s nullglob +files=("$path"/*.md) +shopt -u nullglob + +case "$arg1" in + -e|--edit) + [[ -z "$arg2" ]] && { + echo "Note name is required" + exit 1 + } + + # shellcheck disable=SC2207 + found=($(echo "${files[@]}" | grep -P "[0-9]{10}-$arg2.md")) + [[ ${#found[@]} -eq 0 ]] && { + echo "Note with name '$arg2' not found." + echo "Create it with using 'note $arg2'" + exit + } + + [[ ${#found[@]} -eq 1 ]] && { + nano "${found[0]}" + exit + } + + PS3="Select a note to edit: " + select selection in "${found[@]}" "Exit"; do + [[ "$selection" == "Exit" ]] && exit + [[ -f "$selection" ]] && { + nano "$selection" + exit + } + continue + done + ;; + + *) + [[ -z "$arg2" ]] && arg2="${arg1:-New note}" + file="$path/$(date +%s)-$arg1.md" + cat < "$file" +# $arg2 + +Note taken: $(date '+%d.%m.%Y %H:%M:%S') + +EOF + nano "$file" + ;; +esac diff --git a/scripts/utils/notes b/scripts/utils/notes new file mode 100755 index 0000000..dbc24e3 --- /dev/null +++ b/scripts/utils/notes @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -e +set -o pipefail + +# Notes listing tool +# +# Purpose: +# Lists all markdown notes stored in ~/notes/ directory +# +# Usage: +# notes - Display all available notes +# +# Output: +# - Shows filenames of all .md files in ~/notes/ +# - If no notes exist or directory is empty, displays "Empty" +# - Provides hint to use 'note -e' for editing +# +# Example output: +# 1703123456-my-idea.md +# 1703123789-shopping-list.md +# 1703124012-project-notes.md +# +# Use 'note -e' to edit existing notes + +path="$HOME/notes" + +[[ ! -d "$path" ]] && { + echo "Empty" + exit 0 +} + +shopt -s nullglob +files=("$path"/*.md) +shopt -u nullglob + +[[ "${#files}" -eq 0 ]] && { + echo "Empty" + exit 0 +} +for file in "${files[@]}"; do + echo "${file/$path\//}" +done + +echo +echo "Use 'note -e' to edit existing notes" diff --git a/scripts/utils/now b/scripts/utils/now new file mode 100755 index 0000000..20359c5 --- /dev/null +++ b/scripts/utils/now @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +date '+%d.%m.%Y %H:%M:%S' diff --git a/scripts/utils/pasta b/scripts/utils/pasta new file mode 100755 index 0000000..d04e0a3 --- /dev/null +++ b/scripts/utils/pasta @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e +set -u + +if hash pbpaste 2>/dev/null; then + exec pbpaste +elif hash xclip 2>/dev/null; then + exec xclip -selection clipboard -o +elif [[ -e /tmp/clipboard ]]; then + exec cat /tmp/clipboard +else + echo '' +fi diff --git a/scripts/utils/running b/scripts/utils/running new file mode 100755 index 0000000..268e312 --- /dev/null +++ b/scripts/utils/running @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e +set -u + +process_list="$(ps -eo 'pid command')" +if [[ $# != 0 ]]; then + process_list="$(echo "$process_list" | grep -Fiw "$@")" +fi + +echo "$process_list" | + grep -Fv "${BASH_SOURCE[0]}" | + grep -Fv grep | + GREP_COLORS='mt=00;35' grep -E --colour=auto '^\s*[[:digit:]]+' diff --git a/scripts/utils/scratch b/scripts/utils/scratch new file mode 100755 index 0000000..c8d74ce --- /dev/null +++ b/scripts/utils/scratch @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +file="$(mktemp)" +echo "Editing $file" +exec "$EDITOR" "$file" diff --git a/scripts/utils/serve b/scripts/utils/serve new file mode 100755 index 0000000..3b46767 --- /dev/null +++ b/scripts/utils/serve @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +port='8888' +if [ $# -eq 1 ]; then + port="$1" +fi + +if hash php 2>/dev/null; then + exec php -S "localhost:$port" +elif hash python3 2>/dev/null; then + exec python3 -m http.server "$port" +elif hash python 2>/dev/null; then + major_version="$(python -c 'import platform as p;print(p.python_version_tuple()[0])')" + if [[ "$major_version" == '3' ]]; then + exec python -m http.server "$port" + else + exec python -m SimpleHTTPServer "$port" + fi +else + echo 'unable to start HTTP server' 1>&2 + exit 1 +fi diff --git a/scripts/utils/timer b/scripts/utils/timer new file mode 100755 index 0000000..f092805 --- /dev/null +++ b/scripts/utils/timer @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +sleep "$1" +notify-send 'Timer complete!' \ + -u normal \ + -t 10000 \ + -i clock \ + -a 'Timer script' diff --git a/scripts/utils/trash b/scripts/utils/trash new file mode 100755 index 0000000..72d85b2 --- /dev/null +++ b/scripts/utils/trash @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +gio trash "$@" diff --git a/scripts/utils/tryna b/scripts/utils/tryna new file mode 100755 index 0000000..7050ed0 --- /dev/null +++ b/scripts/utils/tryna @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -u + +"$@" +while [[ ! "$?" -eq 0 ]]; do + sleep 0.5 + "$@" +done diff --git a/scripts/utils/trynafail b/scripts/utils/trynafail new file mode 100755 index 0000000..813be3d --- /dev/null +++ b/scripts/utils/trynafail @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -u + +"$@" +while [[ "$?" -eq 0 ]]; do + sleep 0.5 + "$@" +done diff --git a/scripts/utils/url2md b/scripts/utils/url2md new file mode 100755 index 0000000..79ad4ab --- /dev/null +++ b/scripts/utils/url2md @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +curl "https://r.jina.ai/$1" \ + -sS \ + -H "DNT: 1" \ + -H "X-Base: final" \ + -H "X-Engine: direct" \ + -H "X-Md-Em-Delimiter: *" \ + -H "X-Md-Heading-Style: setext" \ + -H "X-Md-Link-Reference-Style: collapsed" \ + -H "X-Md-Link-Style: referenced" diff --git a/scripts/utils/waitfor b/scripts/utils/waitfor new file mode 100755 index 0000000..e2d7602 --- /dev/null +++ b/scripts/utils/waitfor @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e +set -u +set -o pipefail + +if hash systemd-inhibit 2>/dev/null; then + systemd-inhibit \ + --who=waitfor \ + --why="Awaiting PID $1" \ + tail --pid="$1" -f /dev/null +else + tail --pid="$1" -f /dev/null +fi diff --git a/tools/vscode-ext.sh b/scripts/vscode-ext.sh similarity index 100% rename from tools/vscode-ext.sh rename to scripts/vscode-ext.sh diff --git a/tools/ytdlcue.sh b/scripts/ytdlcue.sh similarity index 100% rename from tools/ytdlcue.sh rename to scripts/ytdlcue.sh