aboutsummaryrefslogtreecommitdiffstats
path: root/sys/nixpkgs/pkgs/scripts/source/small_functions
diff options
context:
space:
mode:
Diffstat (limited to 'sys/nixpkgs/pkgs/scripts/source/small_functions')
-rwxr-xr-xsys/nixpkgs/pkgs/scripts/source/small_functions/nato.py106
-rwxr-xr-xsys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_persistent.sh22
-rwxr-xr-xsys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_temporary.sh8
-rwxr-xr-xsys/nixpkgs/pkgs/scripts/source/small_functions/update-sys.sh77
4 files changed, 213 insertions, 0 deletions
diff --git a/sys/nixpkgs/pkgs/scripts/source/small_functions/nato.py b/sys/nixpkgs/pkgs/scripts/source/small_functions/nato.py
new file mode 100755
index 00000000..e9d15f56
--- /dev/null
+++ b/sys/nixpkgs/pkgs/scripts/source/small_functions/nato.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+# originally from here: https://cgit.pacien.net/desktop-utilities/
+
+import sys
+
+alphabet = {
+ "nato": {
+ "A": "Alfa", # No idea why this is not just 'Alpha' ..
+ "B": "Bravo",
+ "C": "Charlie",
+ "D": "Delta",
+ "E": "Echo",
+ "F": "Foxtrot",
+ "G": "Golf",
+ "H": "Hotel",
+ "I": "India",
+ "J": "Juliett",
+ "K": "Kilo",
+ "L": "Lima",
+ "M": "Mike",
+ "N": "November",
+ "O": "Oscar",
+ "P": "Papa",
+ "Q": "Quebec",
+ "R": "Romeo",
+ "S": "Sierra",
+ "T": "Tango",
+ "U": "Uniform",
+ "V": "Victor",
+ "W": "Whiskey",
+ "X": "X-ray",
+ "Y": "Yankee",
+ "Z": "Zulu",
+ "0": "Nadazero",
+ "1": "Unaone",
+ "2": "Bissotwo",
+ "3": "Terrathree",
+ "4": "Kartefour",
+ "5": "Pantafive",
+ "6": "Soxisix",
+ "7": "Setteseven",
+ "8": "Oktoeight",
+ "9": "Novenine",
+ ",": "Comma",
+ "/": "Forward slash",
+ ".": "Stop/Decimal",
+ },
+ "german": {
+ "A": "Aachen",
+ "Ä": "Umlaut Aachen",
+ "B": "Berlin",
+ "C": "Chemnitz",
+ "D": "Düsseldorf",
+ "E": "Essen",
+ "F": "Frankfurt",
+ "G": "Goslar",
+ "H": "Hamburg",
+ "I": "Ingelheim",
+ "J": "Jena",
+ "K": "Köln",
+ "L": "Leipzig",
+ "M": "München",
+ "N": "Nürnberg",
+ "O": "Offenbach",
+ "Ö": "Umlaut Offenbach",
+ "P": "Potsdam",
+ "Q": "Quickborn",
+ "R": "Rostock",
+ "S": "Salzwedel",
+ "ẞ": "Eszett",
+ "T": "Tübingen",
+ "U": "Unna",
+ "Ü": "Umlaut Unna",
+ "V": "Völklingen",
+ "W": "Wuppertal",
+ "X": "Xanten",
+ "Y": "Ypsilon",
+ "Z": "Zwickau",
+ },
+}
+
+
+def str_to_telephony(phrase, language):
+ language_alphabet = alphabet[language]
+
+ return [
+ language_alphabet[c] if c in language_alphabet else c for c in phrase.upper()
+ ]
+
+
+language = sys.argv[1]
+if language not in ["nato", "german"]:
+ print(
+ f"Langugae '{language}' is not a valid language, only 'nato' and 'german' are!",
+ file=sys.stderr,
+ )
+ exit(1)
+
+print(
+ "\n".join(
+ str_to_telephony(
+ " ".join(sys.argv[2:]),
+ language,
+ )
+ )
+)
diff --git a/sys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_persistent.sh b/sys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_persistent.sh
new file mode 100755
index 00000000..5992e02f
--- /dev/null
+++ b/sys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_persistent.sh
@@ -0,0 +1,22 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
+
+# only generate a path (this could lead to a time-of-check/time-of-use bug)
+tmp="$(mktmp --dry-run)"
+
+if grim -g "$(slurp)" "$tmp"; then
+ name="$(rofi -dmenu -p "Name of screenshot: " -l 0)"
+ screen_shot_path="$HOME/media/pictures/screenshots/$name.png"
+ while [ -f "$screen_shot_path" ]; do
+ notify-send "Warning" 'Screenshot name already in use!'
+ name="$(rofi -dmenu -p "New name of screenshot: " -l 0)"
+ screen_shot_path="$HOME/media/pictures/screenshots/$name.png"
+ done
+
+ mv "$tmp" "$screen_shot_path"
+ alacritty -e lf -command ":{{ set sortby atime; set reverse!; }}"
+fi
+
+# vim: ft=sh
diff --git a/sys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_temporary.sh b/sys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_temporary.sh
new file mode 100755
index 00000000..e411340d
--- /dev/null
+++ b/sys/nixpkgs/pkgs/scripts/source/small_functions/screenshot_temporary.sh
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
+
+grim -g "$(slurp)" | wl-copy
+
+# vim: ft=sh
diff --git a/sys/nixpkgs/pkgs/scripts/source/small_functions/update-sys.sh b/sys/nixpkgs/pkgs/scripts/source/small_functions/update-sys.sh
new file mode 100755
index 00000000..68fb342d
--- /dev/null
+++ b/sys/nixpkgs/pkgs/scripts/source/small_functions/update-sys.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
+
+help() {
+ cat <<EOF
+This is a NixOS System flake update manager.
+
+Usage:
+ $NAME [--branch <branchname>] [--help]
+
+Options:
+ --branch | -b BRANCHNAME
+ select a branch to update from.
+ --mode | -m MODE
+ select a mode to update with
+ --help | -h
+ output this help.
+EOF
+ exit "$1"
+}
+default_branch=$(mktmp)
+BRANCH=""
+
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ "--help" | "-h")
+ help 0
+ ;;
+ "--branch" | "-b")
+ if [ -n "$2" ]; then
+ BRANCH="$2"
+ else
+ error "$1 requires an argument"
+ help 1
+ fi
+ shift 2
+ ;;
+ "--mode" | "-m")
+ if [ -n "$2" ]; then
+ MODE="$2"
+ else
+ error "$1 requires an argument"
+ help 1
+ fi
+ shift 2
+ ;;
+ *)
+ error "the option $1 does not exist!"
+ help 1
+ ;;
+ esac
+done
+
+cd /etc/nixos || die "No /etc/nixos"
+msg "Starting system update..."
+git remote update origin --prune >/dev/null 2>&1
+if ! [ "$BRANCH" = "" ]; then
+ git switch "$BRANCH" >/dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'"
+fi
+msg2 "Updating git repository..."
+git pull --rebase
+
+git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' >"$default_branch" &
+
+msg2 "Updating system..."
+if [ -n "$MODE" ]; then
+ nixos-rebuild "$MODE"
+else
+ nixos-rebuild switch
+fi
+
+git switch "$(cat "$default_branch")" >/dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'"
+msg "Finished Update!"
+
+# vim: ft=sh