diff options
author | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
commit | 3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch) | |
tree | 7164ccd965e1d14ade970aeb8eb188b1442a6c91 /hm/soispha/pkgs/scripts/small_functions | |
parent | Style(treewide): Format all lua-files makes lua ➛ nix easier (diff) | |
download | nixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip |
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'hm/soispha/pkgs/scripts/small_functions')
-rwxr-xr-x | hm/soispha/pkgs/scripts/small_functions/dldragon | 28 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/small_functions/gtk-themes | 21 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/small_functions/mocs | 15 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/small_functions/screen_shot | 10 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/small_functions/update-sys | 78 |
5 files changed, 152 insertions, 0 deletions
diff --git a/hm/soispha/pkgs/scripts/small_functions/dldragon b/hm/soispha/pkgs/scripts/small_functions/dldragon new file mode 100755 index 00000000..ea75c362 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/dldragon @@ -0,0 +1,28 @@ +#! /usr/bin/env dash +# Provides the ability to download a file by dropping it into a window + +url=$(dragon -t -x) + +if [ -n "$url" ]; then + printf "File Name: " + name="" + while [ -z $name ] || [ -e $name ] + do + read -r name + if [ -e "$name" ]; then + printf "File already exists, overwrite (y|n): " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + printf "File Name: " + fi + fi + done + + # Download the file with curl + [ -n "$name" ] && curl -o "$name" "$url" || exit 1 +else + exit 1 +fi diff --git a/hm/soispha/pkgs/scripts/small_functions/gtk-themes b/hm/soispha/pkgs/scripts/small_functions/gtk-themes new file mode 100755 index 00000000..457bc35a --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/gtk-themes @@ -0,0 +1,21 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH + + +# TODO: document, what this does + +# usage: import-gsettings +config="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini" +if [ ! -f "$config" ]; then exit 1; fi + +gnome_schema="org.gnome.desktop.interface" +gtk_theme="$(grep 'gtk-theme-name' "$config" | sed 's/.*\s*=\s*//')" +icon_theme="$(grep 'gtk-icon-theme-name' "$config" | sed 's/.*\s*=\s*//')" +cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | sed 's/.*\s*=\s*//')" +font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')" +gsettings set "$gnome_schema" gtk-theme "$gtk_theme" +gsettings set "$gnome_schema" icon-theme "$icon_theme" +gsettings set "$gnome_schema" cursor-theme "$cursor_theme" +gsettings set "$gnome_schema" font-name "$font_name" diff --git a/hm/soispha/pkgs/scripts/small_functions/mocs b/hm/soispha/pkgs/scripts/small_functions/mocs new file mode 100755 index 00000000..e14a84c8 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/mocs @@ -0,0 +1,15 @@ +#! /bin/bash +if [[ "$(pgrep mocp)" -eq 0 ]]; +then + mocp -M "${XDG_CONFIG_HOME}"/moc -S + if [[ $1 -eq 0 ]]; + then + mocp -M "${XDG_CONFIG_HOME}"/moc -v 12 + else + mocp -M "${XDG_CONFIG_HOME}"/moc -v "$1" + fi + mocp -M "${XDG_CONFIG_HOME}"/moc -p + mymocp& +else + mocp -M "${XDG_CONFIG_HOME}"/moc -G +fi diff --git a/hm/soispha/pkgs/scripts/small_functions/screen_shot b/hm/soispha/pkgs/scripts/small_functions/screen_shot new file mode 100755 index 00000000..73eb2ee4 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/screen_shot @@ -0,0 +1,10 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH + +date="$(date +%s)" +grim -g "$(slurp)" "$HOME/media/pictures/screenshots/$date.png" && + alacritty -e ll -command ":{{ set sortby atime; set reverse!; }}" "$HOME/media/pictures/screenshots/$date.png" + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/small_functions/update-sys b/hm/soispha/pkgs/scripts/small_functions/update-sys new file mode 100755 index 00000000..355682d1 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/update-sys @@ -0,0 +1,78 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="1.1.4" . %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 |