From 08a332d0daa13e52e4c8ae9bf2dbcb6408041a34 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Wed, 15 Mar 2023 14:09:28 +0100 Subject: Cleaned up some scripts --- scripts/.local/bin/personal/adbreset | 3 + scripts/.local/bin/personal/appmenu | 8 - scripts/.local/bin/personal/bar/battery | 29 +- scripts/.local/bin/personal/bar/brightness | 43 +-- scripts/.local/bin/personal/bar/datetime | 2 +- scripts/.local/bin/personal/bar/inputlang | 18 ++ scripts/.local/bin/personal/bar/load | 2 +- scripts/.local/bin/personal/bar/music | 2 +- scripts/.local/bin/personal/bar/mute | 6 +- scripts/.local/bin/personal/bar/status | 14 +- scripts/.local/bin/personal/bar/temp | 4 +- scripts/.local/bin/personal/bar/updates | 4 +- scripts/.local/bin/personal/books | 3 + scripts/.local/bin/personal/colorconvert | 28 -- scripts/.local/bin/personal/compile | 25 +- scripts/.local/bin/personal/dlmusic | 2 +- scripts/.local/bin/personal/ed | 27 -- scripts/.local/bin/personal/eve | 3 - scripts/.local/bin/personal/ext/lfub | 24 -- scripts/.local/bin/personal/ext/panes | 23 -- scripts/.local/bin/personal/ext/pipes.sh | 385 -------------------------- scripts/.local/bin/personal/ext/rotdir | 12 - scripts/.local/bin/personal/ext/xdg-open | 13 - scripts/.local/bin/personal/external/extract | 23 ++ scripts/.local/bin/personal/external/lfub | 24 ++ scripts/.local/bin/personal/external/mailsync | 89 ++++++ scripts/.local/bin/personal/external/panes | 23 ++ scripts/.local/bin/personal/external/pipes.sh | 385 ++++++++++++++++++++++++++ scripts/.local/bin/personal/external/rotdir | 12 + scripts/.local/bin/personal/extract | 23 -- scripts/.local/bin/personal/getibusinput | 11 - scripts/.local/bin/personal/hdmi | 8 +- scripts/.local/bin/personal/infoboard | 24 +- scripts/.local/bin/personal/ipscan | 5 + scripts/.local/bin/personal/kivytest | 30 -- scripts/.local/bin/personal/klimperklamper | 129 --------- scripts/.local/bin/personal/launchworkingenv | 4 +- scripts/.local/bin/personal/lockscreen | 8 - scripts/.local/bin/personal/mats | 5 - scripts/.local/bin/personal/musctl | 33 +++ scripts/.local/bin/personal/notification | 13 + scripts/.local/bin/personal/powermenu | 5 +- scripts/.local/bin/personal/prepare | 9 - scripts/.local/bin/personal/rica | 24 +- scripts/.local/bin/personal/rmfc | 26 ++ scripts/.local/bin/personal/screenshot | 14 + scripts/.local/bin/personal/syshealth | 38 +++ scripts/.local/bin/personal/tabura | 3 - scripts/.local/bin/personal/volctl | 1 + scripts/.local/bin/personal/wally | 7 +- scripts/.local/bin/personal/wrapper/dmenu | 19 ++ scripts/.local/bin/personal/wrapper/stabbed | 5 + scripts/.local/bin/personal/wrapper/tabura | 5 + scripts/.local/bin/personal/wrapper/xdg-open | 18 ++ scripts/.local/bin/personal/zeit | 5 - 55 files changed, 852 insertions(+), 856 deletions(-) create mode 100755 scripts/.local/bin/personal/adbreset delete mode 100755 scripts/.local/bin/personal/appmenu create mode 100755 scripts/.local/bin/personal/bar/inputlang create mode 100755 scripts/.local/bin/personal/books delete mode 100755 scripts/.local/bin/personal/colorconvert delete mode 100755 scripts/.local/bin/personal/ed delete mode 100755 scripts/.local/bin/personal/eve delete mode 100755 scripts/.local/bin/personal/ext/lfub delete mode 100755 scripts/.local/bin/personal/ext/panes delete mode 100755 scripts/.local/bin/personal/ext/pipes.sh delete mode 100755 scripts/.local/bin/personal/ext/rotdir delete mode 100755 scripts/.local/bin/personal/ext/xdg-open create mode 100755 scripts/.local/bin/personal/external/extract create mode 100755 scripts/.local/bin/personal/external/lfub create mode 100755 scripts/.local/bin/personal/external/mailsync create mode 100755 scripts/.local/bin/personal/external/panes create mode 100755 scripts/.local/bin/personal/external/pipes.sh create mode 100755 scripts/.local/bin/personal/external/rotdir delete mode 100755 scripts/.local/bin/personal/extract delete mode 100755 scripts/.local/bin/personal/getibusinput create mode 100755 scripts/.local/bin/personal/ipscan delete mode 100755 scripts/.local/bin/personal/kivytest delete mode 100755 scripts/.local/bin/personal/klimperklamper delete mode 100755 scripts/.local/bin/personal/lockscreen delete mode 100755 scripts/.local/bin/personal/mats create mode 100755 scripts/.local/bin/personal/musctl create mode 100755 scripts/.local/bin/personal/notification delete mode 100755 scripts/.local/bin/personal/prepare create mode 100755 scripts/.local/bin/personal/rmfc create mode 100755 scripts/.local/bin/personal/screenshot create mode 100755 scripts/.local/bin/personal/syshealth delete mode 100755 scripts/.local/bin/personal/tabura create mode 100755 scripts/.local/bin/personal/wrapper/dmenu create mode 100755 scripts/.local/bin/personal/wrapper/stabbed create mode 100755 scripts/.local/bin/personal/wrapper/tabura create mode 100755 scripts/.local/bin/personal/wrapper/xdg-open delete mode 100755 scripts/.local/bin/personal/zeit diff --git a/scripts/.local/bin/personal/adbreset b/scripts/.local/bin/personal/adbreset new file mode 100755 index 0000000..b8baa7c --- /dev/null +++ b/scripts/.local/bin/personal/adbreset @@ -0,0 +1,3 @@ +#/bin/bash + +adb kill-server && adb start-server || echo "Error" diff --git a/scripts/.local/bin/personal/appmenu b/scripts/.local/bin/personal/appmenu deleted file mode 100755 index 3c96a8f..0000000 --- a/scripts/.local/bin/personal/appmenu +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Launching -rofi -no-lazy-grab -show drun \ --display-drun "Applications :" -drun-display-format "{name}" \ --matching fuzzy \ --font "Hack 20" \ - diff --git a/scripts/.local/bin/personal/bar/battery b/scripts/.local/bin/personal/bar/battery index 53c1cb0..151202e 100755 --- a/scripts/.local/bin/personal/bar/battery +++ b/scripts/.local/bin/personal/bar/battery @@ -1,27 +1,14 @@ #!/bin/bash -percent="$(acpi | awk '{print $4}')" -state="$(acpi | awk '{print $3}')" -time="$(acpi | awk '{print $5}')" +acpireport="$(acpi | grep -v unavailable | head -n 1)" -state0="" -state1="" -state2="" -state3="" -state4="" +percent="$(echo $acpireport | awk '{print $4}')" +state="$(echo $acpireport | awk '{print $3}')" +time="$(echo $acpireport | awk '{print $5}')" -if [[ "$1" = "condition" ]]; then - if ((${percent::-2} <= 10)) ; then - echo "1" - else - echo "0" - fi - - exit 0 -fi - -if [ "${state::-1}" == "Discharging" ]; then - echo "${percent::-1} (${time::-3} ↓)" +if [[ "${state::-1}" == "Discharging" ]]; then + echo "${percent::-1} | ${time::-3} ↓" else - echo "${percent::-1} (${time::-3} ↑)" + echo "${percent::-1} | ${time::-3} ↑" fi + diff --git a/scripts/.local/bin/personal/bar/brightness b/scripts/.local/bin/personal/bar/brightness index 681c846..c1a117e 100755 --- a/scripts/.local/bin/personal/bar/brightness +++ b/scripts/.local/bin/personal/bar/brightness @@ -4,8 +4,11 @@ # Depends on: bash, brightnessctl # By David Penkowoj, 2021/06/24 -MTR_VALUE=19 -KBD_VALUE=2 +# MTR_DEVICE="$MTR_DEVICE" +MTR_DEVICE="acpi_video0" +KBD_DEVICE="smc::kbd_backlight" +MTR_VALUE=75 +KBD_VALUE=0 SWITCH="$1" @@ -22,46 +25,50 @@ case $SWITCH in printf "status - show brightness of a device" ;; "load") - brightnessctl --device='intel_backlight' set "$MTR_VALUE%" - brightnessctl --device='smc::kbd_backlight' set 0 # "$KBD_VALUE%" + brightnessctl --device="$MTR_DEVICE" set "$MTR_VALUE%" + brightnessctl --device="$KBD_DEVICE" set 0 # "$KBD_VALUE%" ;; "save") - M="$(brightnessctl --device='intel_backlight' | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" - K="$(brightnessctl --device='smc::kbd_backlight' | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" + M="$(brightnessctl --device="$MTR_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" + K="$(brightnessctl --device="$KBD_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" sed -i "s/MTR_VALUE=$MTR_VALUE/MTR_VALUE=$M/g" "$0" sed -i "s/KBD_VALUE=$KBD_VALUE/KBD_VALUE=$K/g" "$0" ;; "smalldown") - if [[ "$2" = "monitor" ]]; then brightnessctl --device='intel_backlight' set 1-%; fi - if [[ "$2" = "keyboard" ]]; then brightnessctl --device='smc::kbd_backlight' set 1-%; fi + if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set 1-%; fi + if [[ "$2" = "keyboard" ]]; then brightnessctl --device="$KBD_DEVICE" set 1-%; fi brightness save + notify-send -u low -r "110" "$2: $(brightness get monitor)" ;; "smallup") - if [[ "$2" = "monitor" ]]; then brightnessctl --device='intel_backlight' set +1%; fi - if [[ "$2" = "keyboard" ]]; then brightnessctl --device='smc::kbd_backlight' set +1%; fi + if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set +1%; fi + if [[ "$2" = "keyboard" ]]; then brightnessctl --device="$KBD_DEVICE" set +1%; fi brightness save + notify-send -u low -r "110" "$2: $(brightness get monitor)" ;; "down") - if [[ "$2" = "monitor" ]]; then brightnessctl --device='intel_backlight' set 5-%; fi - if [[ "$2" = "keyboard" ]]; then brightnessctl --device='smc::kbd_backlight' set 5-%; fi + if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set 5-%; fi + if [[ "$2" = "keyboard" ]]; then brightnessctl --device="$KBD_DEVICE" set 5-%; fi brightness save + notify-send -u low -r "110" "$2: $(brightness get monitor)" ;; "up") - if [[ "$2" = "monitor" ]]; then brightnessctl --device='intel_backlight' set +5%; fi - if [[ "$2" = "keyboard" ]]; then brightnessctl --device='smc::kbd_backlight' set +5%; fi + if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set +5%; fi + if [[ "$2" = "keyboard" ]]; then brightnessctl --device="$KBD_DEVICE" set +5%; fi brightness save + notify-send -u low -r "110" "$2: $(brightness get monitor)" ;; "get") - M="$(brightnessctl --device='intel_backlight' | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" - K="$(brightnessctl --device='smc::kbd_backlight' | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" + M="$(brightnessctl --device="$MTR_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" + K="$(brightnessctl --device="$KBD_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" if [[ "$2" = "monitor" ]]; then echo "$M%"; fi if [[ "$2" = "keyboard" ]]; then echo "$K%"; fi ;; *) printf "Monitor:\n" - brightnessctl --device='intel_backlight' | tail -n 3 | sed 's/\t/- /g' + brightnessctl --device="$MTR_DEVICE" | tail -n 3 | sed 's/\t/- /g' printf "Keyboard:\n" - brightnessctl --device='smc::kbd_backlight' | tail -n 3 | sed 's/\t/- /g' + brightnessctl --device="$KBD_DEVICE" | tail -n 3 | sed 's/\t/- /g' ;; esac diff --git a/scripts/.local/bin/personal/bar/datetime b/scripts/.local/bin/personal/bar/datetime index 31f2144..d11713b 100755 --- a/scripts/.local/bin/personal/bar/datetime +++ b/scripts/.local/bin/personal/bar/datetime @@ -5,5 +5,5 @@ if [ "$1" = "date" ]; then elif [ "$1" = "time" ]; then echo "$(date '+%H:%M %Z')" else - echo "$(date '+%a. %Y-%m-%d %H:%M %Z')" + echo "$(date '+%a. %Y-%m-%d | %H:%M %Z')" fi diff --git a/scripts/.local/bin/personal/bar/inputlang b/scripts/.local/bin/personal/bar/inputlang new file mode 100755 index 0000000..810ba0f --- /dev/null +++ b/scripts/.local/bin/personal/bar/inputlang @@ -0,0 +1,18 @@ +#!/bin/bash + +langstring="$(fcitx5-remote -n)" + +case $SWITCH in + "keyboard-de") + echo "DE" + ;; + "keyboard-de-ru") + echo "RU" + ;; + "kkc") + echo "JA" + ;; + *) + echo "OS" # meaning oh sht + ;; +esac diff --git a/scripts/.local/bin/personal/bar/load b/scripts/.local/bin/personal/bar/load index dec7f60..706ae91 100755 --- a/scripts/.local/bin/personal/bar/load +++ b/scripts/.local/bin/personal/bar/load @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/dash grep 'cpu ' /proc/stat | awk '{cpu_usage=($2+$4)*100/($2+$4+$5)} {printf "%0.2f%", cpu_usage}' printf "\n" diff --git a/scripts/.local/bin/personal/bar/music b/scripts/.local/bin/personal/bar/music index 54104b0..f425553 100755 --- a/scripts/.local/bin/personal/bar/music +++ b/scripts/.local/bin/personal/bar/music @@ -5,7 +5,7 @@ NAME="$(mpc current | xargs -i basename '{}')" VOLUME="$(mpc volume | awk '{print $2}')" if [[ -n "$STATE" ]]; then - echo "MPD Playing: ${NAME%.*} ($VOLUME)" + echo "Currently playing: ${NAME%.*} ($VOLUME)" else echo "MPD Paused" fi diff --git a/scripts/.local/bin/personal/bar/mute b/scripts/.local/bin/personal/bar/mute index 1103c0e..834618a 100755 --- a/scripts/.local/bin/personal/bar/mute +++ b/scripts/.local/bin/personal/bar/mute @@ -6,9 +6,9 @@ if [[ "$1" == "shortstatus" ]]; then VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)" if [[ "$VOLUME" == "0%" ]]; then - echo "OFF" + echo "Muted" else - echo "ON" + echo "" fi exit @@ -25,7 +25,9 @@ fi if [[ "$(pactl get-source-volume $SOURCE | grep -o [0-9]*%)" == "0%" ]]; then pactl set-source-volume "$SOURCE" 70% + notify-send -u low "Unmuted" -r 110 else pactl set-source-volume "$SOURCE" 0% + notify-send -u low "Muted" -r 110 fi diff --git a/scripts/.local/bin/personal/bar/status b/scripts/.local/bin/personal/bar/status index 10c33de..e6dbbb9 100755 --- a/scripts/.local/bin/personal/bar/status +++ b/scripts/.local/bin/personal/bar/status @@ -7,13 +7,13 @@ SEPARATOR=" " # default color button use() { - printf "%s^c%s^^b%s^ %s ^b%s^ %s ^b%s^" "$SEPARATOR" "$color0" "$color1" "$1" "$color2" "$2" "$color0" + printf "%s^c%s^^b%s^ %s ^b%s^ %s ^b%s^" "$SEPARATOR" "$background" "$color1" "$1" "$color9" "$2" "$background" } # show in specified color if specified condition is true usecolorif() { if [ "$3" = "1" ]; then - printf "%s^c%s^^b%s^ %s ^c%s^^b%s^ %s ^b%s^" "$SEPARATOR" "$color1" "$color0" "$1" "$color2" "$color0" "$2" "$color0" + printf "%s^c%s^^b%s^ %s ^c%s^^b%s^ %s ^b%s^" "$SEPARATOR" "$color1" "$background" "$1" "$color9" "$color0" "$2" "$background" else use "$1" "$2" fi @@ -27,4 +27,12 @@ useif() { } # actual string -echo "$(useif "" "$(updates read)")$(useif "" "$(volume)")$(use "" "$(lights)")$(usecolorif "ﴞ" "$(battery)" "$(battery condition)")$(useif "說" "$(network)")$(use "" "$(datetime time)")$(use "" "$(datetime date)")" +echo "\ +$(useif "" "$(updates read)")\ +$(useif "󰍬" "$(mute shortstatus)")\ +$(useif "󰕾" "$(volume)")\ +$(useif "說" "$(network)")\ +$(use "󰘚" "$(load) | $(temp)")\ +$(use "󱐋" "$(battery)")\ +$(use "" "$(datetime)")\ +" diff --git a/scripts/.local/bin/personal/bar/temp b/scripts/.local/bin/personal/bar/temp index 4a9589f..c4c19bb 100755 --- a/scripts/.local/bin/personal/bar/temp +++ b/scripts/.local/bin/personal/bar/temp @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/dash -echo "$(sensors | grep "Package id 0:" | awk '{print $4}')" +echo "$(sensors | grep "Package id 0:" | awk '{print $4}' | sed 's/+//g')" diff --git a/scripts/.local/bin/personal/bar/updates b/scripts/.local/bin/personal/bar/updates index c0a3f4a..9db1bff 100755 --- a/scripts/.local/bin/personal/bar/updates +++ b/scripts/.local/bin/personal/bar/updates @@ -1,6 +1,6 @@ -#!/bin/dash +#!/bin/bash -storage=0 +storage=29 if [ "$1" = "read" ]; then if [ "$storage" != "0" ]; then diff --git a/scripts/.local/bin/personal/books b/scripts/.local/bin/personal/books new file mode 100755 index 0000000..11d92c7 --- /dev/null +++ b/scripts/.local/bin/personal/books @@ -0,0 +1,3 @@ +#!/bin/bash + +tabbed -c zathura /home/me/documents/books/lehrbücher/analysis/*.pdf -e diff --git a/scripts/.local/bin/personal/colorconvert b/scripts/.local/bin/personal/colorconvert deleted file mode 100755 index 6777f23..0000000 --- a/scripts/.local/bin/personal/colorconvert +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import colorsys - -def hsl2hex(color): - # regex = r'hsl\(\s*(\d+),\s*(\d+)%,\s*(\d+)%\s*\);' - # lines = [re.findall(regex,line) for line in one_dark_syn.split('\n')] - # rgbs = [colorsys.hsv_to_rgb(int(line[1][0])/360, int(line[0][1])/100, int(line[0][2])/100) for line in lines if line] - # rgbhex = ["".join("%03X" % round(i*255) for i in rgb) for rgb in rgbs] - - colors = color.split(",") - color_rgb_frac = colorsys.hls_to_rgb(int(colors[0]) / 360, int(colors[2]) / 100, int(color[1]) / 100) - print(color_rgb_frac) - color_rgb = [round(value / 255) for value in color_rgb_frac] - print(color_rgb) - color_hex = [",".join("%3X" % rgb for rgb in color_rgb)] - print(color_hex) - return color_hex - -# https://www.rapidtables.com/convert/color/hsl-to-rgb.html - -if __name__ == "__main__": - if sys.argv[1] == "hsl2hex": - print(hsl2hex(sys.argv[2])) - else: - print("Usage example:\ncolorconvert hsl2hex 78,50,60") - diff --git a/scripts/.local/bin/personal/compile b/scripts/.local/bin/personal/compile index 028ae11..c5643b8 100755 --- a/scripts/.local/bin/personal/compile +++ b/scripts/.local/bin/personal/compile @@ -1,8 +1,10 @@ #!/bin/bash # A script to compile any (here defined) type of text file to a target format -# Depends on: bash, basename, pdflatex, pandoc, asciidoctor +# Depends on: bash, basename, pdflatex, pandoc, asciidoctor, make # By David Penkowoj, 2021/08/02 +# +# Usage: compile {file} [--no-make] # Function to compile .md to .pdf files ADOC_TO_HTML() { @@ -36,16 +38,35 @@ MD_TO_PDF() { sed '/^!.*/d' "$1" > "$TMP" && # This enables comments with "!" sed 's/^\\!/!/g' "$TMP" "$TMP" && # This enables escaping with "\!" - pandoc "$TMP" -o "$2.pdf" && + pandoc "$TMP" --template "$HOME/documents/templates/abgaben.latex" -o "$2.pdf" && printf "Successfully compiled %s to %s\n" "$1" "$2.pdf" || printf "[ Error ] Couldn't compile %s\n" "$1" } +# Function to run the make command if possible +RUN_MAKE() { + cd "$1" && + make auto && + printf "Successfully made project\n" || + printf "[ Error ] Couldn't make project\n" +} + # Check if file exists if [[ -e "$1" ]]; then # Determine filename and extension FILENAME="$(basename -- "$1")" EXTENSION="${FILENAME##*.}" + FILEPATH="$(pwd)/$1" + DIRECTORY="${FILEPATH%/*}" + + # If make file exists, run make and exit + if [[ -e "$DIRECTORY/makefile" ]] || [[ -e "$DIRECTORY/Makefile" ]]; then + echo "$2" + if [[ "$2" != "--no-make" ]]; then + RUN_MAKE "$DIRECTORY" + exit 0 + fi + fi # Check if there is a extension at all if [[ "$FILENAME" == "$EXTENSION" ]]; then diff --git a/scripts/.local/bin/personal/dlmusic b/scripts/.local/bin/personal/dlmusic index c0177ac..3bd414c 100755 --- a/scripts/.local/bin/personal/dlmusic +++ b/scripts/.local/bin/personal/dlmusic @@ -4,7 +4,7 @@ # Yes I am lazy. if [[ -n "$1" ]]; then - youtube-dl "$1" --extract-audio -i -o "%(title)s.%(ext)s" --audio-format mp3 && + yt-dlp "$1" --extract-audio -i -o "%(title)s.%(ext)s" --audio-format mp3 --cookies "~/.config/cookies.txt" && exit 0 || exit 1 else diff --git a/scripts/.local/bin/personal/ed b/scripts/.local/bin/personal/ed deleted file mode 100755 index 9e7b99f..0000000 --- a/scripts/.local/bin/personal/ed +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# A script to start editing files -# Dependencies: bash, basename, date -# By David Penkowoj, 2022-02-18 - -# implement: fzf -f QUERY - -DATE="$(date +'%Y-%m-%d')" -FILE="$(basename $1)" -DIR="$(dirname $1)" - -if [[ "$DIR" = "." ]]; then - if [[ -f "$DATE-A-$FILE" ]]; then - "$EDITOR" "$DATE-A-$FILE" - else - "$EDITOR" "$DATE-B-$FILE" - fi -else - cd "$DIR" - if [[ -f "$DATE-A-$FILE" ]]; then - "$EDITOR" "$DATE-A-$FILE" - else - "$EDITOR" "$DATE-B-$FILE" - fi -fi - diff --git a/scripts/.local/bin/personal/eve b/scripts/.local/bin/personal/eve deleted file mode 100755 index 556bde0..0000000 --- a/scripts/.local/bin/personal/eve +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -wally "$(ls /home/me/images/wallpapers | dmenu)" diff --git a/scripts/.local/bin/personal/ext/lfub b/scripts/.local/bin/personal/ext/lfub deleted file mode 100755 index 9012f50..0000000 --- a/scripts/.local/bin/personal/ext/lfub +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# This is a wrapper script for lb that allows it to create image previews with -# ueberzug. This works in concert with the lf configuration file and the -# lf-cleaner script. - -set -e - -cleanup() { - exec 3>&- - rm "$FIFO_UEBERZUG" -} - -if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - lf "$@" -else - [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf" - export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$" - mkfifo "$FIFO_UEBERZUG" - ueberzug layer -s <"$FIFO_UEBERZUG" -p json & - exec 3>"$FIFO_UEBERZUG" - trap cleanup HUP INT QUIT TERM PWR EXIT - lf "$@" 3>&- -fi diff --git a/scripts/.local/bin/personal/ext/panes b/scripts/.local/bin/personal/ext/panes deleted file mode 100755 index a191de8..0000000 --- a/scripts/.local/bin/personal/ext/panes +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -# Author: GekkoP -# Source: http://linuxbbq.org/bbs/viewtopic.php?f=4&t=1656#p33189 - -f=3 b=4 -for j in f b; do - for i in {0..7}; do - printf -v $j$i %b "\e[${!j}${i}m" - done -done -d=$'\e[1m' -t=$'\e[0m' -v=$'\e[7m' - - -cat << EOF - - $f1███$d▄$t $f2███$d▄$t $f3███$d▄$t $f4███$d▄$t $f5███$d▄$t $f6███$d▄$t $f7███$d▄$t - $f1███$d█$t $f2███$d█$t $f3███$d█$t $f4███$d█$t $f5███$d█$t $f6███$d█$t $f7███$d█$t - $f1███$d█$t $f2███$d█$t $f3███$d█$t $f4███$d█$t $f5███$d█$t $f6███$d█$t $f7███$d█$t - $d$f1 ▀▀▀ $f2▀▀▀ $f3▀▀▀ $f4▀▀▀ $f5▀▀▀ $f6▀▀▀ $f7▀▀▀ -EOF diff --git a/scripts/.local/bin/personal/ext/pipes.sh b/scripts/.local/bin/personal/ext/pipes.sh deleted file mode 100755 index 73346ef..0000000 --- a/scripts/.local/bin/personal/ext/pipes.sh +++ /dev/null @@ -1,385 +0,0 @@ -#!/usr/bin/env bash -# pipes.sh: Animated pipes terminal screensaver. -# https://github.com/pipeseroni/pipes.sh -# -# Copyright (c) 2015-2018 Pipeseroni/pipes.sh contributors -# Copyright (c) 2013-2015 Yu-Jie Lin -# Copyright (c) 2010 Matthew Simpson -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - - -VERSION=1.3.0 - -M=32768 # Bash RANDOM maximum + 1 -p=1 # number of pipes -f=75 # frame rate -s=13 # probability of straight fitting -r=2000 # characters limit -t=0 # iteration counter for -r character limit -w=80 # terminal size -h=24 - -# ab -> sets[][idx] = a*4 + b -# 0: up, 1: right, 2: down, 3: left -# 00 means going up , then going up -> ┃ -# 12 means going right, then going down -> ┓ -sets=( - "┃┏ ┓┛━┓ ┗┃┛┗ ┏━" - "│╭ ╮╯─╮ ╰│╯╰ ╭─" - "│┌ ┐┘─┐ └│┘└ ┌─" - "║╔ ╗╝═╗ ╚║╝╚ ╔═" - "|+ ++-+ +|++ +-" - "|/ \/-\ \|/\ /-" - ".. .... .... .." - ".o oo.o o.oo o." - "-\ /\|/ /-\/ \|" # railway - "╿┍ ┑┚╼┒ ┕╽┙┖ ┎╾" # knobby pipe -) -SETS=() # rearranged all pipe chars into individul elements for easier access - -# pipes' -x=() # current position -y=() -l=() # current directions - # 0: up, 1: right, 2: down, 3: left -n=() # new directions -v=() # current types -c=() # current escape codes - -# selected pipes' -V=() # types (indexes to sets[]) -C=() # color indices for tput setaf -VN=0 # number of selected types -CN=0 # number of selected colors -E=() # pre-generated escape codes from BOLD, NOCOLOR, and C - -# switches -RNDSTART=0 # randomize starting position and direction -BOLD=1 -NOCOLOR=0 -KEEPCT=0 # keep pipe color and type - - -# print help message in 72-char width -print_help() { - local cgap - printf -v cgap '%*s' $((15 - ${#COLORS})) '' - cat <= 0 - is_N() { - [[ -n $1 && -z ${1//[0-9]} ]] - } - - - # test if $1 is a hexadecimal string - is_hex() { - [[ -n $1 && -z ${1//[0-9A-Fa-f]} ]] - } - - - # print error message for invalid argument to standard error, this - # - mimics getopts error message - # - use all positional parameters as error message - # - has a newline appended - # $arg and $OPTARG are the option name and argument set by getopts. - pearg() { - printf "%s: -$arg invalid argument -- $OPTARG; %s\n" "$0" "$*" >&2 - } - - - OPTIND=1 - while getopts "p:t:c:f:s:r:RBCKhv" arg; do - case $arg in - p) - if is_N "$OPTARG" && ((OPTARG > 0)); then - p=$OPTARG - else - pearg 'must be an integer and greater than 0' - return 1 - fi - ;; - t) - if [[ "$OPTARG" = c???????????????? ]]; then - V+=(${#sets[@]}) - sets+=("${OPTARG:1}") - elif is_N "$OPTARG" && ((OPTARG < ${#sets[@]})); then - V+=($OPTARG) - else - pearg 'must be an integer and from 0 to' \ - "$((${#sets[@]} - 1)); or a custom type" - return 1 - fi - ;; - c) - if [[ $OPTARG == '#'* ]]; then - if ! is_hex "${OPTARG:1}"; then - pearg 'unrecognized hexadecimal string' - return 1 - fi - if ((16$OPTARG >= COLORS)); then - pearg 'hexadecimal must be from #0 to' \ - "#$(printf '%X' $((COLORS - 1)))" - return 1 - fi - C+=($((16$OPTARG))) - elif is_N "$OPTARG" && ((OPTARG < COLORS)); then - C+=($OPTARG) - else - pearg "must be an integer and from 0 to $((COLORS - 1));" \ - 'or a hexadecimal string with # prefix' - return 1 - fi - ;; - f) - if is_N "$OPTARG" && ((OPTARG >= 20 && OPTARG <= 100)); then - f=$OPTARG - else - pearg 'must be an integer and from 20 to 100' - return 1 - fi - ;; - s) - if is_N "$OPTARG" && ((OPTARG >= 5 && OPTARG <= 15)); then - s=$OPTARG - else - pearg 'must be an integer and from 5 to 15' - return 1 - fi - ;; - r) - if is_N "$OPTARG"; then - r=$OPTARG - else - pearg 'must be a non-negative integer' - return 1 - fi - ;; - R) RNDSTART=1;; - B) BOLD=0;; - C) NOCOLOR=1;; - K) KEEPCT=1;; - h) - print_help - exit 0 - ;; - v) echo "$(basename -- "$0") $VERSION" - exit 0 - ;; - *) - return 1 - esac - done - - shift $((OPTIND - 1)) - if (($#)); then - printf "$0: illegal arguments -- $*; no arguments allowed\n" >&2 - return 1 - fi -} - - -cleanup() { - # clear out standard input - read -t 0.001 && cat /dev/null - - tput reset # fix for konsole, see pipeseroni/pipes.sh#43 - tput rmcup - tput cnorm - stty echo - printf "$SGR0" - exit 0 -} - - -resize() { - w=$(tput cols) h=$(tput lines) -} - - -init_pipes() { - # +_CP_init_pipes - local i - - ci=$((KEEPCT ? 0 : CN * RANDOM / M)) - vi=$((KEEPCT ? 0 : VN * RANDOM / M)) - for ((i = 0; i < p; i++)); do - (( - n[i] = 0, - l[i] = RNDSTART ? RANDOM % 4 : 0, - x[i] = RNDSTART ? w * RANDOM / M : w / 2, - y[i] = RNDSTART ? h * RANDOM / M : h / 2, - v[i] = V[vi] - )) - c[i]=${E[ci]} - ((ci = (ci + 1) % CN, vi = (vi + 1) % VN)) - done - # -_CP_init_pipes -} - - -init_screen() { - stty -echo - tput smcup - tput civis - tput clear - trap cleanup HUP TERM - - resize - trap resize SIGWINCH -} - - -main() { - # simple pre-check of TERM, tput's error message should be enough - tput -T "$TERM" sgr0 >/dev/null || return $? - - # +_CP_init_termcap_vars - COLORS=$(tput colors) # COLORS - 1 == maximum color index for -c argument - SGR0=$(tput sgr0) - SGR_BOLD=$(tput bold) - # -_CP_init_termcap_vars - - parse "$@" || return $? - - # +_CP_init_VC - # set default values if not by options - ((${#V[@]})) || V=(0) - VN=${#V[@]} - ((${#C[@]})) || C=(1 2 3 4 5 6 7 0) - CN=${#C[@]} - # -_CP_init_VC - - # +_CP_init_E - # generate E[] based on BOLD (SGR_BOLD), NOCOLOR, and C for each element in - # C, a corresponding element in E[] = - # SGR0 - # + SGR_BOLD, if BOLD - # + tput setaf C, if !NOCOLOR - local i - for ((i = 0; i < CN; i++)) { - E[i]=$SGR0 - ((BOLD)) && E[i]+=$SGR_BOLD - ((NOCOLOR)) || E[i]+=$(tput setaf ${C[i]}) - } - # -_CP_init_E - - # +_CP_init_SETS - local i j - for ((i = 0; i < ${#sets[@]}; i++)) { - for ((j = 0; j < 16; j++)) { - SETS+=("${sets[i]:j:1}") - } - } - unset i j - # -_CP_init_SETS - - init_screen - init_pipes - - # any key press exits the loop and this script - trap 'break 2' INT - - local i - while REPLY=; do - read -t 0.0$((1000 / f)) -n 1 2>/dev/null - case "$REPLY" in - P) ((s = s < 15 ? s + 1 : s));; - O) ((s = s > 3 ? s - 1 : s));; - F) ((f = f < 100 ? f + 1 : f));; - D) ((f = f > 20 ? f - 1 : f));; - B) ((BOLD = (BOLD + 1) % 2));; - C) ((NOCOLOR = (NOCOLOR + 1) % 2));; - K) ((KEEPCT = (KEEPCT + 1) % 2));; - ?) break;; - esac - for ((i = 0; i < p; i++)); do - # New position: - # l[] direction = 0: up, 1: right, 2: down, 3: left - # +_CP_newpos - ((l[i] % 2)) && ((x[i] += -l[i] + 2, 1)) || ((y[i] += l[i] - 1)) - # -_CP_newpos - - # Loop on edges (change color on loop): - # +_CP_warp - ((!KEEPCT && (x[i] >= w || x[i] < 0 || y[i] >= h || y[i] < 0))) \ - && { c[i]=${E[CN * RANDOM / M]}; ((v[i] = V[VN * RANDOM / M])); } - ((x[i] = (x[i] + w) % w, - y[i] = (y[i] + h) % h)) - # -_CP_warp - - # new turning direction: - # $((s - 1)) in $s, going straight, therefore n[i] == l[i]; - # and 1 in $s that pipe makes a right or left turn - # - # s * RANDOM / M - 1 == 0 - # n[i] == -1 - # => n[i] == l[i] + 1 or l[i] - 1 - # +_CP_newdir - (( - n[i] = s * RANDOM / M - 1, - n[i] = n[i] >= 0 ? l[i] : l[i] + (2 * (RANDOM % 2) - 1), - n[i] = (n[i] + 4) % 4 - )) - # -_CP_newdir - - # Print: - # +_CP_print - printf '\e[%d;%dH%s%s' \ - $((y[i] + 1)) $((x[i] + 1)) ${c[i]} \ - "${SETS[v[i] * 16 + l[i] * 4 + n[i]]}" - # -_CP_print - l[i]=${n[i]} - done - ((r > 0 && t * p >= r)) && tput reset && tput civis && t=0 || ((t++)) - done - - cleanup -} - - -# when being sourced, $0 == bash, only invoke main when they are the same -[[ "$0" != "$BASH_SOURCE" ]] || main "$@" diff --git a/scripts/.local/bin/personal/ext/rotdir b/scripts/.local/bin/personal/ext/rotdir deleted file mode 100755 index 86da6db..0000000 --- a/scripts/.local/bin/personal/ext/rotdir +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# When I open an image from the file manager in sxiv (the image viewer), I want -# to be able to press the next/previous keys to key through the rest of the -# images in the same directory. This script "rotates" the content of a -# directory based on the first chosen file, so that if I open the 15th image, -# if I press next, it will go to the 16th etc. Autistic, I know, but this is -# one of the reasons that sxiv is great for being able to read standard input. - -[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 -base="$(basename "$1")" -ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }' diff --git a/scripts/.local/bin/personal/ext/xdg-open b/scripts/.local/bin/personal/ext/xdg-open deleted file mode 100755 index 3136dda..0000000 --- a/scripts/.local/bin/personal/ext/xdg-open +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -case "${1%%:*}" in - http|https|*.pdf) - exec qutebrowser "$1" - ;; - mailto) - exec aerc "$1" - ;; - *) - exec /usr/bin/xdg-open "$@" - ;; -esac diff --git a/scripts/.local/bin/personal/external/extract b/scripts/.local/bin/personal/external/extract new file mode 100755 index 0000000..082136b --- /dev/null +++ b/scripts/.local/bin/personal/external/extract @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar -xvjf $1 --one-top-level ;; + *.tar.gz) tar -xvzf $1 --one-top-level ;; + # *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + # *.Z) uncompress $1;; + # * .7z) 7z x $1 ;; + *.deb) ar x $1 ;; + *.tar.xz) tar xf $1 ;; + *.tar.zst) tar xf $1 ;; + *) echo "'$1' cannot be extracted" ;; + esac +else + echo "'$1' is not a valid file" +fi diff --git a/scripts/.local/bin/personal/external/lfub b/scripts/.local/bin/personal/external/lfub new file mode 100755 index 0000000..9012f50 --- /dev/null +++ b/scripts/.local/bin/personal/external/lfub @@ -0,0 +1,24 @@ +#!/bin/sh + +# This is a wrapper script for lb that allows it to create image previews with +# ueberzug. This works in concert with the lf configuration file and the +# lf-cleaner script. + +set -e + +cleanup() { + exec 3>&- + rm "$FIFO_UEBERZUG" +} + +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + lf "$@" +else + [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf" + export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$" + mkfifo "$FIFO_UEBERZUG" + ueberzug layer -s <"$FIFO_UEBERZUG" -p json & + exec 3>"$FIFO_UEBERZUG" + trap cleanup HUP INT QUIT TERM PWR EXIT + lf "$@" 3>&- +fi diff --git a/scripts/.local/bin/personal/external/mailsync b/scripts/.local/bin/personal/external/mailsync new file mode 100755 index 0000000..72cce26 --- /dev/null +++ b/scripts/.local/bin/personal/external/mailsync @@ -0,0 +1,89 @@ +#!/bin/sh + +# Stolen from https://github.com/LukeSmithxyz/mutt-wizard/blob/master/bin/mailsync +# and modified to suit my needs + +# - Syncs mail for all accounts, or a single account given as an argument. +# - Displays a notification showing the number of new mails. +# - Displays a notification for each new mail with its subject displayed. +# - Runs notmuch to index new mail. +# - This script can be set up as a cron job for automated mail syncing. + +# There are many arbitrary and ugly features in this script because it is +# inherently difficult to pass environmental variables to cronjobs and other +# issues. It also should at least be compatible with Linux (and maybe BSD) with +# Xorg and MacOS as well. + +# Run only if user logged in (prevent cron errors) +pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} +# Run only if not already running in other instance +pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;} + +# First, we have to get the right variables for the mbsync file, the pass +# archive, notmuch and the GPG home. This is done by searching common profile +# files for variable assignments. This is ugly, but there are few options that +# will work on the maximum number of machines. +eval "$(grep -h -- \ + "^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \ + "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \ + "$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \ + "$HOME/.pam_environment" 2>/dev/null)" + +export GPG_TTY="$(tty)" + +[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" + +lastrun="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" + +# Settings are different for MacOS (Darwin) systems. +case "$(readlink -f /sbin/init)" in + *systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; +esac + +# remember if a display server is running since `ps` doesn't always contain a display +pgrepoutput="$(pgrep -a X\(org\|wayland\))" +displays="$(echo "$pgrepoutput" | grep -wo "[0-9]*:[0-9]\+" | sort -u)" +notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do + export DISPLAY=$x + notification "New mail!" "Fully synced $1" & +done ;} + +# Check account for new mail. Notify if there is new content. +syncandnotify() { + acc="$(echo "$account" | sed "s/.*\///")" + if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi + new=$(find\ + "$HOME/.local/share/mail/$acc/INBOX/new/"\ + "$HOME/.local/share/mail/$acc/Inbox/new/"\ + "$HOME/.local/share/mail/$acc/inbox/new/"\ + "$HOME/.local/share/mail/$acc/INBOX/cur/"\ + "$HOME/.local/share/mail/$acc/Inbox/cur/"\ + "$HOME/.local/share/mail/$acc/inbox/cur/"\ + -type f -newer "$lastrun" 2> /dev/null) + newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) + case 1 in + $((newcount > 0)) ) notify "$acc" "$newcount" ;; + esac +} + +# Sync accounts passed as argument or all. +if [ "$#" -eq "0" ]; then + accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" +else + for arg in "$@"; do + [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 + done + accounts=$* +fi + +# Parallelize multiple accounts +for account in $accounts; do + syncandnotify & +done + +wait + +notmuch new 2>/dev/null + +#Create a touch file that indicates the time of the last run of mailsync +touch "$lastrun" diff --git a/scripts/.local/bin/personal/external/panes b/scripts/.local/bin/personal/external/panes new file mode 100755 index 0000000..a191de8 --- /dev/null +++ b/scripts/.local/bin/personal/external/panes @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Author: GekkoP +# Source: http://linuxbbq.org/bbs/viewtopic.php?f=4&t=1656#p33189 + +f=3 b=4 +for j in f b; do + for i in {0..7}; do + printf -v $j$i %b "\e[${!j}${i}m" + done +done +d=$'\e[1m' +t=$'\e[0m' +v=$'\e[7m' + + +cat << EOF + + $f1███$d▄$t $f2███$d▄$t $f3███$d▄$t $f4███$d▄$t $f5███$d▄$t $f6███$d▄$t $f7███$d▄$t + $f1███$d█$t $f2███$d█$t $f3███$d█$t $f4███$d█$t $f5███$d█$t $f6███$d█$t $f7███$d█$t + $f1███$d█$t $f2███$d█$t $f3███$d█$t $f4███$d█$t $f5███$d█$t $f6███$d█$t $f7███$d█$t + $d$f1 ▀▀▀ $f2▀▀▀ $f3▀▀▀ $f4▀▀▀ $f5▀▀▀ $f6▀▀▀ $f7▀▀▀ +EOF diff --git a/scripts/.local/bin/personal/external/pipes.sh b/scripts/.local/bin/personal/external/pipes.sh new file mode 100755 index 0000000..73346ef --- /dev/null +++ b/scripts/.local/bin/personal/external/pipes.sh @@ -0,0 +1,385 @@ +#!/usr/bin/env bash +# pipes.sh: Animated pipes terminal screensaver. +# https://github.com/pipeseroni/pipes.sh +# +# Copyright (c) 2015-2018 Pipeseroni/pipes.sh contributors +# Copyright (c) 2013-2015 Yu-Jie Lin +# Copyright (c) 2010 Matthew Simpson +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +VERSION=1.3.0 + +M=32768 # Bash RANDOM maximum + 1 +p=1 # number of pipes +f=75 # frame rate +s=13 # probability of straight fitting +r=2000 # characters limit +t=0 # iteration counter for -r character limit +w=80 # terminal size +h=24 + +# ab -> sets[][idx] = a*4 + b +# 0: up, 1: right, 2: down, 3: left +# 00 means going up , then going up -> ┃ +# 12 means going right, then going down -> ┓ +sets=( + "┃┏ ┓┛━┓ ┗┃┛┗ ┏━" + "│╭ ╮╯─╮ ╰│╯╰ ╭─" + "│┌ ┐┘─┐ └│┘└ ┌─" + "║╔ ╗╝═╗ ╚║╝╚ ╔═" + "|+ ++-+ +|++ +-" + "|/ \/-\ \|/\ /-" + ".. .... .... .." + ".o oo.o o.oo o." + "-\ /\|/ /-\/ \|" # railway + "╿┍ ┑┚╼┒ ┕╽┙┖ ┎╾" # knobby pipe +) +SETS=() # rearranged all pipe chars into individul elements for easier access + +# pipes' +x=() # current position +y=() +l=() # current directions + # 0: up, 1: right, 2: down, 3: left +n=() # new directions +v=() # current types +c=() # current escape codes + +# selected pipes' +V=() # types (indexes to sets[]) +C=() # color indices for tput setaf +VN=0 # number of selected types +CN=0 # number of selected colors +E=() # pre-generated escape codes from BOLD, NOCOLOR, and C + +# switches +RNDSTART=0 # randomize starting position and direction +BOLD=1 +NOCOLOR=0 +KEEPCT=0 # keep pipe color and type + + +# print help message in 72-char width +print_help() { + local cgap + printf -v cgap '%*s' $((15 - ${#COLORS})) '' + cat <= 0 + is_N() { + [[ -n $1 && -z ${1//[0-9]} ]] + } + + + # test if $1 is a hexadecimal string + is_hex() { + [[ -n $1 && -z ${1//[0-9A-Fa-f]} ]] + } + + + # print error message for invalid argument to standard error, this + # - mimics getopts error message + # - use all positional parameters as error message + # - has a newline appended + # $arg and $OPTARG are the option name and argument set by getopts. + pearg() { + printf "%s: -$arg invalid argument -- $OPTARG; %s\n" "$0" "$*" >&2 + } + + + OPTIND=1 + while getopts "p:t:c:f:s:r:RBCKhv" arg; do + case $arg in + p) + if is_N "$OPTARG" && ((OPTARG > 0)); then + p=$OPTARG + else + pearg 'must be an integer and greater than 0' + return 1 + fi + ;; + t) + if [[ "$OPTARG" = c???????????????? ]]; then + V+=(${#sets[@]}) + sets+=("${OPTARG:1}") + elif is_N "$OPTARG" && ((OPTARG < ${#sets[@]})); then + V+=($OPTARG) + else + pearg 'must be an integer and from 0 to' \ + "$((${#sets[@]} - 1)); or a custom type" + return 1 + fi + ;; + c) + if [[ $OPTARG == '#'* ]]; then + if ! is_hex "${OPTARG:1}"; then + pearg 'unrecognized hexadecimal string' + return 1 + fi + if ((16$OPTARG >= COLORS)); then + pearg 'hexadecimal must be from #0 to' \ + "#$(printf '%X' $((COLORS - 1)))" + return 1 + fi + C+=($((16$OPTARG))) + elif is_N "$OPTARG" && ((OPTARG < COLORS)); then + C+=($OPTARG) + else + pearg "must be an integer and from 0 to $((COLORS - 1));" \ + 'or a hexadecimal string with # prefix' + return 1 + fi + ;; + f) + if is_N "$OPTARG" && ((OPTARG >= 20 && OPTARG <= 100)); then + f=$OPTARG + else + pearg 'must be an integer and from 20 to 100' + return 1 + fi + ;; + s) + if is_N "$OPTARG" && ((OPTARG >= 5 && OPTARG <= 15)); then + s=$OPTARG + else + pearg 'must be an integer and from 5 to 15' + return 1 + fi + ;; + r) + if is_N "$OPTARG"; then + r=$OPTARG + else + pearg 'must be a non-negative integer' + return 1 + fi + ;; + R) RNDSTART=1;; + B) BOLD=0;; + C) NOCOLOR=1;; + K) KEEPCT=1;; + h) + print_help + exit 0 + ;; + v) echo "$(basename -- "$0") $VERSION" + exit 0 + ;; + *) + return 1 + esac + done + + shift $((OPTIND - 1)) + if (($#)); then + printf "$0: illegal arguments -- $*; no arguments allowed\n" >&2 + return 1 + fi +} + + +cleanup() { + # clear out standard input + read -t 0.001 && cat /dev/null + + tput reset # fix for konsole, see pipeseroni/pipes.sh#43 + tput rmcup + tput cnorm + stty echo + printf "$SGR0" + exit 0 +} + + +resize() { + w=$(tput cols) h=$(tput lines) +} + + +init_pipes() { + # +_CP_init_pipes + local i + + ci=$((KEEPCT ? 0 : CN * RANDOM / M)) + vi=$((KEEPCT ? 0 : VN * RANDOM / M)) + for ((i = 0; i < p; i++)); do + (( + n[i] = 0, + l[i] = RNDSTART ? RANDOM % 4 : 0, + x[i] = RNDSTART ? w * RANDOM / M : w / 2, + y[i] = RNDSTART ? h * RANDOM / M : h / 2, + v[i] = V[vi] + )) + c[i]=${E[ci]} + ((ci = (ci + 1) % CN, vi = (vi + 1) % VN)) + done + # -_CP_init_pipes +} + + +init_screen() { + stty -echo + tput smcup + tput civis + tput clear + trap cleanup HUP TERM + + resize + trap resize SIGWINCH +} + + +main() { + # simple pre-check of TERM, tput's error message should be enough + tput -T "$TERM" sgr0 >/dev/null || return $? + + # +_CP_init_termcap_vars + COLORS=$(tput colors) # COLORS - 1 == maximum color index for -c argument + SGR0=$(tput sgr0) + SGR_BOLD=$(tput bold) + # -_CP_init_termcap_vars + + parse "$@" || return $? + + # +_CP_init_VC + # set default values if not by options + ((${#V[@]})) || V=(0) + VN=${#V[@]} + ((${#C[@]})) || C=(1 2 3 4 5 6 7 0) + CN=${#C[@]} + # -_CP_init_VC + + # +_CP_init_E + # generate E[] based on BOLD (SGR_BOLD), NOCOLOR, and C for each element in + # C, a corresponding element in E[] = + # SGR0 + # + SGR_BOLD, if BOLD + # + tput setaf C, if !NOCOLOR + local i + for ((i = 0; i < CN; i++)) { + E[i]=$SGR0 + ((BOLD)) && E[i]+=$SGR_BOLD + ((NOCOLOR)) || E[i]+=$(tput setaf ${C[i]}) + } + # -_CP_init_E + + # +_CP_init_SETS + local i j + for ((i = 0; i < ${#sets[@]}; i++)) { + for ((j = 0; j < 16; j++)) { + SETS+=("${sets[i]:j:1}") + } + } + unset i j + # -_CP_init_SETS + + init_screen + init_pipes + + # any key press exits the loop and this script + trap 'break 2' INT + + local i + while REPLY=; do + read -t 0.0$((1000 / f)) -n 1 2>/dev/null + case "$REPLY" in + P) ((s = s < 15 ? s + 1 : s));; + O) ((s = s > 3 ? s - 1 : s));; + F) ((f = f < 100 ? f + 1 : f));; + D) ((f = f > 20 ? f - 1 : f));; + B) ((BOLD = (BOLD + 1) % 2));; + C) ((NOCOLOR = (NOCOLOR + 1) % 2));; + K) ((KEEPCT = (KEEPCT + 1) % 2));; + ?) break;; + esac + for ((i = 0; i < p; i++)); do + # New position: + # l[] direction = 0: up, 1: right, 2: down, 3: left + # +_CP_newpos + ((l[i] % 2)) && ((x[i] += -l[i] + 2, 1)) || ((y[i] += l[i] - 1)) + # -_CP_newpos + + # Loop on edges (change color on loop): + # +_CP_warp + ((!KEEPCT && (x[i] >= w || x[i] < 0 || y[i] >= h || y[i] < 0))) \ + && { c[i]=${E[CN * RANDOM / M]}; ((v[i] = V[VN * RANDOM / M])); } + ((x[i] = (x[i] + w) % w, + y[i] = (y[i] + h) % h)) + # -_CP_warp + + # new turning direction: + # $((s - 1)) in $s, going straight, therefore n[i] == l[i]; + # and 1 in $s that pipe makes a right or left turn + # + # s * RANDOM / M - 1 == 0 + # n[i] == -1 + # => n[i] == l[i] + 1 or l[i] - 1 + # +_CP_newdir + (( + n[i] = s * RANDOM / M - 1, + n[i] = n[i] >= 0 ? l[i] : l[i] + (2 * (RANDOM % 2) - 1), + n[i] = (n[i] + 4) % 4 + )) + # -_CP_newdir + + # Print: + # +_CP_print + printf '\e[%d;%dH%s%s' \ + $((y[i] + 1)) $((x[i] + 1)) ${c[i]} \ + "${SETS[v[i] * 16 + l[i] * 4 + n[i]]}" + # -_CP_print + l[i]=${n[i]} + done + ((r > 0 && t * p >= r)) && tput reset && tput civis && t=0 || ((t++)) + done + + cleanup +} + + +# when being sourced, $0 == bash, only invoke main when they are the same +[[ "$0" != "$BASH_SOURCE" ]] || main "$@" diff --git a/scripts/.local/bin/personal/external/rotdir b/scripts/.local/bin/personal/external/rotdir new file mode 100755 index 0000000..86da6db --- /dev/null +++ b/scripts/.local/bin/personal/external/rotdir @@ -0,0 +1,12 @@ +#!/bin/sh + +# When I open an image from the file manager in sxiv (the image viewer), I want +# to be able to press the next/previous keys to key through the rest of the +# images in the same directory. This script "rotates" the content of a +# directory based on the first chosen file, so that if I open the 15th image, +# if I press next, it will go to the 16th etc. Autistic, I know, but this is +# one of the reasons that sxiv is great for being able to read standard input. + +[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 +base="$(basename "$1")" +ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }' diff --git a/scripts/.local/bin/personal/extract b/scripts/.local/bin/personal/extract deleted file mode 100755 index b51c413..0000000 --- a/scripts/.local/bin/personal/extract +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar -xvjf $1 --one-top-level ;; - *.tar.gz) tar -xvzf $1 --one-top-level ;; - # *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xf $1 ;; - *.tbz2) tar xjf $1 ;; - *.tgz) tar xzf $1 ;; - *.zip) unzip $1 ;; - # *.Z) uncompress $1;; - # * .7z) 7z x $1 ;; - *.deb) ar x $1 ;; - *.tar.xz) tar xf $1 ;; - *.tar.zst) tar xf $1 ;; - *) echo "'$1' cannot be extracted via ex()" ;; - esac -else - echo "'$1' is not a valid file" -fi diff --git a/scripts/.local/bin/personal/getibusinput b/scripts/.local/bin/personal/getibusinput deleted file mode 100755 index 4d52273..0000000 --- a/scripts/.local/bin/personal/getibusinput +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -STRING="$(ibus read-config | grep -o engines-order:.* | sed 's/engines-order: \[\|\]\|,//g' | awk '{ print $1 }')" - -if [[ "$STRING" == "'xkb:de::deu'" ]]; then - echo "DE" -elif [[ "$STRING" == "'anthy'" ]]; then - echo "JA" -elif [[ "$STRING" == "'xkb:de:ru:rus'" ]]; then - echo "RU" -fi diff --git a/scripts/.local/bin/personal/hdmi b/scripts/.local/bin/personal/hdmi index ea687ef..b1918f2 100755 --- a/scripts/.local/bin/personal/hdmi +++ b/scripts/.local/bin/personal/hdmi @@ -1,14 +1,8 @@ #!/bin/bash -# HDMI_ACTIVE="$(xrandr | grep ' connected' | grep 'HDMI' | awk '{print $1}')" - -# if [[ ! -z "$HDMI_ACTIVE" ]]; then -# echo "active" -# fi - HDMI_ACTIVE="$(grep '^connected' /sys/class/drm/card0/*HDMI*/status)" if [[ ! -z "$HDMI_ACTIVE" ]]; then - echo active + notify-send "HDMI Connected" fi diff --git a/scripts/.local/bin/personal/infoboard b/scripts/.local/bin/personal/infoboard index a220709..e2f494a 100755 --- a/scripts/.local/bin/personal/infoboard +++ b/scripts/.local/bin/personal/infoboard @@ -1,25 +1,3 @@ #!/bin/bash -# bspc desktop -f '^11' && -# -# windows="$(bspc query -N -d '^11' -n .window)" -# -# if [ "$windows" = "2" ] -# then - # exit 0; -# else - # for number in {$windows} - # do - # bspc node -c && sleep 0.1 - # done -# - # kitty zsh -c ". ~/.config/zsh/.zshrc; zeit" & - # kitty zsh -c ". ~/.config/zsh/.zshrc; cmatrix" & -# fi - -if [[ -n "$(eww windows | grep -o '\*')" ]]; then - eww close info -else - eww open info -fi - +notify-send -u low "Not configured" diff --git a/scripts/.local/bin/personal/ipscan b/scripts/.local/bin/personal/ipscan new file mode 100755 index 0000000..c764f01 --- /dev/null +++ b/scripts/.local/bin/personal/ipscan @@ -0,0 +1,5 @@ +#!/bin/bash + +net="$(ip r | grep -v default | awk '{print $1}' | dmenu -p a)" +echo -e "Please wait while scanning $net\n" +nmap -sn "$net" | grep "Nmap scan report for" | sed 's/(\|)//g' | awk '{print $5 " " $6}' | column -t diff --git a/scripts/.local/bin/personal/kivytest b/scripts/.local/bin/personal/kivytest deleted file mode 100755 index 55699ed..0000000 --- a/scripts/.local/bin/personal/kivytest +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 - -import kivy -import random - -from kivy.app import App -from kivy.uix.button import Button -from kivy.uix.boxlayout import BoxLayout - -red = [1,0,0,1] -green = [0,1,0,1] -blue = [0,0,1,1] -purple = [1,0,1,1] - -class h1(App): - def build(self): - layout = BoxLayout(padding=20) - colors = [red, green, blue, purple] - - for i in range(8): - btn = Button(text="Button #%s" % (i+1), - background_color=random.choice(colors) - ) - - layout.add_widget(btn) - return layout - -if __name__ == "__main__": - app = h1() - app.run() diff --git a/scripts/.local/bin/personal/klimperklamper b/scripts/.local/bin/personal/klimperklamper deleted file mode 100755 index 6bd15ad..0000000 --- a/scripts/.local/bin/personal/klimperklamper +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python3 - -import random -import sys -import os - -slowLength = [ 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 ] -mediumLength = [ 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4 ] -fastLength = [ 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16 ] -notes = [ "c", "cis", "d", "dis", "e", "f", "fis", "g", "gis", "a", "ais", "b" ] -string = '\\version "2.22.1"\n\\header {\ntitle = "Die Dissonanz der Schulzeit"\nsubtitle = "Musik Klausurersatzleistung"\ncomposer = "David Penkowoj"\ncopyright = ""\ntagline = ""\n}\n\\score {\n\\fixed c\' {\n\\time 4/4\n\\tempo "Allegro" 4 = 160\n' - -variationDict = { - "normal": [], - "mirror": [], - "reverse": [], - "reverseMirror": [], -} - -def mirror(noteCopy): - result = [] - mirrorAxisNote = noteCopy[0] - baseIndex = notes.index(mirrorAxisNote) - - for note in noteCopy: - index = notes.index(note) - newNoteIndex = index + (- 2 * (index - baseIndex)) - - result.append(notes[newNoteIndex % len(notes)]) - - return result - -def reverse(noteCopy): - return noteCopy[::-1] - -def reverseMirror(noteCopy): - return mirror(noteCopy)[::-1] - -def randomVariation(rand): - rand = random.randrange(1, 5) - - if rand == 1: - return variationDict["normal"].copy(), "Grundreihe" - if rand == 2: - return variationDict["mirror"].copy(), "Umkehrung" - if rand == 3: - return variationDict["reverse"].copy(), "Krebs" - if rand == 4: - return variationDict["reverseMirror"].copy(), "Krebsumkehrung" - -def getLength(notesCopy, location): - lengthList = [] - - if location <= 1 or location >= 7: - lengthList = slowLength.copy() - elif location >= 3 and location <= 5: - lengthList = fastLength.copy() - else: - lengthList = mediumLength.copy() - - # asd - - return lengthList - -def changeLength(notesCopy, location): - for note in notesCopy: - index = notesCopy.index(note) - rand = random.choice(lengthList) - notesCopy[index] = (f"{note}{rand} ") - lengthList.remove(rand) - - return notesCopy - -def generateRows(): - notesCopy = notes.copy() - random.shuffle(notesCopy) - - variationDict["normal"] = notesCopy - variationDict["mirror"] = mirror(notesCopy) - variationDict["reverse"] = reverse(notesCopy) - variationDict["reverseMirror"] = reverseMirror(notesCopy) - -def makeMusescore(): - global string - - string = "#!/usr/local/bin/xdotool\n\n" - - generateRows() - - for i in range(4): - articualtedVariation, variationType = randomVariation(i) - getLength(articualtedVariation, i) - - variation = " ".join(articualtedVariation) - string = f"{string}type {variation}\nkey Enter\n" - - with open("/tmp/klimperklamper", "w") as file: - file.write(string) - file.close() - - os.system("nvim /tmp/klimperklamper") - -def makePDF(): - global string - - generateRows() - - for i in range(8): - articualtedVariation, variationType = randomVariation() - changeLength(articualtedVariation, i) - - variation = " ".join(articualtedVariation) - string = f"{string}\\mark \\markup \\smaller \\italic {variationType} {variation}|\\break\n" - string = string + "}\n\\midi {} \n\\layout {\nindent = 0\\mm\n}\n}" - - with open("/tmp/klimperklamper", "w") as file: - file.write(string) - file.close() - - os.system("nvim /tmp/klimperklamper") - os.system("lilypond -o /tmp/klimperklamper /tmp/klimperklamper") - os.system("zathura /tmp/klimperklamper.pdf") - -if __name__ == "__main__": - if sys.argv[1] == "musescore": - makeMusescore() - else: - makePDF() - diff --git a/scripts/.local/bin/personal/launchworkingenv b/scripts/.local/bin/personal/launchworkingenv index 5b35542..5dcc203 100755 --- a/scripts/.local/bin/personal/launchworkingenv +++ b/scripts/.local/bin/personal/launchworkingenv @@ -1,5 +1,3 @@ #!/bin/bash -# bspc desktop -f '^1' && -# kitty -d documents & -tabura & +books diff --git a/scripts/.local/bin/personal/lockscreen b/scripts/.local/bin/personal/lockscreen deleted file mode 100755 index bf4e825..0000000 --- a/scripts/.local/bin/personal/lockscreen +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -[ -e "/tmp/lockscrot.png" ] && sudo rm /tmp/lockscrot.png -[ -e "/etc/lightdm/lockscreen.png" ] && sudo rm /etc/lightdm/lockscreen.png - -scrot -e 'sudo mv -f $f /tmp/lockscrot.png' -sudo convert /tmp/lockscrot.png -filter Gaussian -blur 0x15 /etc/lightdm/lockscreen.png -dm-tool lock diff --git a/scripts/.local/bin/personal/mats b/scripts/.local/bin/personal/mats deleted file mode 100755 index 747e1d1..0000000 --- a/scripts/.local/bin/personal/mats +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -wmname LG3D -# exec matlab -r "s = settings;s.matlab.desktop.DisplayScaleFactor.PersonalValue=2;quit" -nodesktop -nosplash -matlab -nosplash diff --git a/scripts/.local/bin/personal/musctl b/scripts/.local/bin/personal/musctl new file mode 100755 index 0000000..4437f37 --- /dev/null +++ b/scripts/.local/bin/personal/musctl @@ -0,0 +1,33 @@ +#!/bin/bash + +STATE="$(mpc | grep -o playing)" +NAME="$(basename "$(mpc current)")" + +notify() { + if [[ -n "$STATE" ]]; then + notify-send "Currently playing" "${NAME%.*}" + else + notify-send "MPD is currently paused" + fi +} + +case "$1" in + "prev") + mpc -q prev + playerctl -s previous + ;; + "toggle") + mpc -q toggle + playerctl -s play-pause + ;; + "next") + mpc -q next + playerctl -s next + ;; + "notify") + notify + ;; + *) + echo "[ Error ] Unknown command" + ;; +esac diff --git a/scripts/.local/bin/personal/notification b/scripts/.local/bin/personal/notification new file mode 100755 index 0000000..062f190 --- /dev/null +++ b/scripts/.local/bin/personal/notification @@ -0,0 +1,13 @@ +#!/bin/bash + +i=100 + +while [ $i -ne 0 ] +do + dunstify -u normal -r 1 -h int:value:$i "$1" + i=$(($i-1)) + sleep 0.02 # ~ 2 seonds? +done + +dunstify -u low -C 1 + diff --git a/scripts/.local/bin/personal/powermenu b/scripts/.local/bin/personal/powermenu index 0a26582..4f42878 100755 --- a/scripts/.local/bin/personal/powermenu +++ b/scripts/.local/bin/personal/powermenu @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash UPTIME=$(uptime -p | sed -e 's/up //g') DWM_PID="$(pidof dwm)" @@ -10,7 +10,7 @@ OPTION_LOGOUT="Logout" OPTION_LOCK="Lock" OPTIONS="$OPTION_CANCEL\n$OPTION_SHUTDOWN\n$OPTION_REBOOT\n$OPTION_LOCK\n$OPTION_LOGOUT" -SELECTED="$(echo -e "$OPTIONS" | dmenu -i -l 5 -p "Uptime: $UPTIME" -z 700 -h 30 -y 900 -x 1090 -fn 'JetBrains Mono:size=19')" +SELECTED="$(echo -e "$OPTIONS" | dmenu -i -l 5 -p "Uptime: $UPTIME" -z 700 -h 30 -y 900 -x 1090 -fn 'JetBrains Mono:size=8')" case $SELECTED in $OPTION_SHUTDOWN) @@ -20,6 +20,7 @@ case $SELECTED in sudo systemctl reboot ;; $OPTION_LOCK) + sleep 0.2 slock ;; $OPTION_LOGOUT) diff --git a/scripts/.local/bin/personal/prepare b/scripts/.local/bin/personal/prepare deleted file mode 100755 index bb6d231..0000000 --- a/scripts/.local/bin/personal/prepare +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# sudo networkctl up enp0s31f6 -# sudo dhcpcd enp0s31f6 - -xset -dpms -xset s noblank -xset s off - diff --git a/scripts/.local/bin/personal/rica b/scripts/.local/bin/personal/rica index 178f2fc..8a597cc 100755 --- a/scripts/.local/bin/personal/rica +++ b/scripts/.local/bin/personal/rica @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # A script to update the colors in specific config files for easy ricing. -# Depenencies: # By David Penkowoj, 2022-03-18 import os @@ -15,7 +14,7 @@ def replace_color_configs(): new_colors = [ color.replace("\n", "") for color in new_color_file.readlines() ] for config in relevant: - config(old_colors, new_colors) + find_and_replace_config(config, old_colors, new_colors) def find_and_replace_config(file_path, old_colors, new_colors): with open(file_path, "r") as file: @@ -29,26 +28,15 @@ def find_and_replace_config(file_path, old_colors, new_colors): with open(file_path, "w") as file: file.write(data) -# Change config for zathura -def change_zathura(old_colors, new_colors): - file_path = "/home/me/.config/zathura/zathurarc" - - find_and_replace_config(file_path, old_colors, new_colors) - -def change_qutebrowser(old_colors, new_colors): - file_path = "/home/me/.config/qutebrowser/utils.py" - - find_and_replace_config(file_path, old_colors, new_colors) - -# change_nvim -# change_dunst, - relevant = [ - change_zathura, - change_qutebrowser, + "/home/me/.config/dunst/dunstrc", + "/home/me/.config/zathura/zathurarc", + "/home/me/.config/flameshot/flameshot.ini", + "/home/me/.config/qutebrowser/utils.py", ] if __name__ == "__main__": os.system('xrdb -merge "$HOME/.cache/wal/colors.Xresources"') os.system('xrdb -merge "$HOME/.Xresources"') replace_color_configs() + os.system('killall dunst') diff --git a/scripts/.local/bin/personal/rmfc b/scripts/.local/bin/personal/rmfc new file mode 100755 index 0000000..7ad13cb --- /dev/null +++ b/scripts/.local/bin/personal/rmfc @@ -0,0 +1,26 @@ +#!/bin/bash + +REMOTE="http://rmfc.davidpenkowoj.de" + +if [[ "$1" = "-auth" ]]; then + xdg-open "$REMOTE/generatecode" + RMAPI_HOST="$REMOTE:3000" rmapi + exit 0 +fi + +REMOTE_FILE="$1" +LOCAL_FILE="$(basename "$1")" +CONFIG_DIR="$HOME/documents/remarkable/rm2pdf" + +RMAPI_HOST="$REMOTE/" rmapi -ni get "$REMOTE_FILE" +FETCH_STATUS="$?" + +if [[ -e "$LOCAL_FILE.zip" && "$FETCH_STATUS" = "0" ]]; then + rm2pdf -t="$CONFIG_DIR/P Dots Custom.pdf" -s="$CONFIG_DIR/config.yml" "$LOCAL_FILE.zip" "$LOCAL_FILE.pdf" + rm "$LOCAL_FILE.zip" + + echo "[ Info ] Done!" +else + echo "[ Error ] Stopped!" +fi + diff --git a/scripts/.local/bin/personal/screenshot b/scripts/.local/bin/personal/screenshot new file mode 100755 index 0000000..594340b --- /dev/null +++ b/scripts/.local/bin/personal/screenshot @@ -0,0 +1,14 @@ +#!/bin/bash + +notify() { + notify-send "Screenshot saved" "images/screenshots/$(date +%F_%H-%M)" +} + +case "$1" in + "full") + flameshot full -p "$HOME/images/screenshots" && notify ;; + "select") + flameshot gui -p "$HOME/images/screenshots" && notify ;; + *) + notify-send "Error" "Couldn't save screenshot" ;; +esac diff --git a/scripts/.local/bin/personal/syshealth b/scripts/.local/bin/personal/syshealth new file mode 100755 index 0000000..b60b122 --- /dev/null +++ b/scripts/.local/bin/personal/syshealth @@ -0,0 +1,38 @@ +#!/bin/bash + +# NOTE: This script is run by cron periodically + +export XDG_RUNTIME_DIR="/run/user/$(id -u)" + +acpi_report="$(acpi | grep -v unavailable | head -n 1)" +sensors_report="$(sensors | grep "Package id 0:")" + +# Battery charge check +local_percent="$(echo $acpi_report | awk '{print $4}')" +local_state="$(echo $acpi_report | awk '{print $3}')" +local_time="$(echo $acpi_report | awk '{print $5}')" + +battery_message=("Warning: " "Battery charge critical") +temperature_message=("Warning: " "Core temperature critical") + +if ((${local_percent::-2} <= 15)); then + if [[ "${local_state::-1}" == "Discharging" ]]; then + notify-send "${battery_message[0]}" "${battery_message[1]}" -u critical + # espeak "${battery_message[0]}${battery_message[1]}" + fi +elif ((${local_percent::-2} >= 90)); then + if [[ "${local_state::-1}" == "Charging" ]]; then + notify-send "${battery_message[0]}" "${battery_message[1]}" -u critical + # espeak "${battery_message[0]}${battery_message[1]}" + fi +fi + +# Core temperature check +local_temp="$(echo $sensors_report | awk '{print $4}' | sed 's/+//g')" +local_temp_high="$(echo $sensors_report | awk '{print $7}' | sed 's/+//g')" + +if ((${local_temp::-4} >= 90)); then + notify-send "${temperature_message[0]}" "${temperature_message[1]}" -u critical + # espeak "${temperature_message[0]}${temperature_message[1]}" +fi + diff --git a/scripts/.local/bin/personal/tabura b/scripts/.local/bin/personal/tabura deleted file mode 100755 index 1ebdece..0000000 --- a/scripts/.local/bin/personal/tabura +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -tabbed -c zathura -e diff --git a/scripts/.local/bin/personal/volctl b/scripts/.local/bin/personal/volctl index 6dc6e6b..0a3625f 100755 --- a/scripts/.local/bin/personal/volctl +++ b/scripts/.local/bin/personal/volctl @@ -13,6 +13,7 @@ then pactl set-sink-volume "$sink" -5% elif [ "$1" = "mute" ] then + # TODO: Make this a toggle with memory pactl set-sink-volume "$sink" 0% elif [ "$1" = "check" ] then diff --git a/scripts/.local/bin/personal/wally b/scripts/.local/bin/personal/wally index 22f3f11..d05bfad 100755 --- a/scripts/.local/bin/personal/wally +++ b/scripts/.local/bin/personal/wally @@ -15,7 +15,8 @@ setTheme() { echo "Overwriting previous color backup with current colors." mv "$HOME/.cache/wal/colors" "$HOME/.cache/wal/oldcolors" echo "Generating new color scheme." - wal -i "$1" -b "#1a1a1a" --saturate "$saturation" + wal -i "$1" -b "#1a1a1a" --saturate "$saturation" --cols16 + # wal -i "$1" -b "#ffffff" --saturate "$saturation" --cols16 -l echo "Caching wallpaper." cp "$1" "$cachedWallpaperFile" echo "Setting wallpaper." @@ -29,14 +30,14 @@ setTheme() { if [[ -n "$3" ]]; then echo "Got saturation value '$3'." saturation="$3" -else +else echo "Did not recieve saturation value as third argument" fi if [[ -n "$2" ]]; then echo "Got backend value '$2'." backend="$2" -else +else echo "Did not recieve backend value as second argument" fi diff --git a/scripts/.local/bin/personal/wrapper/dmenu b/scripts/.local/bin/personal/wrapper/dmenu new file mode 100755 index 0000000..ef03598 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/dmenu @@ -0,0 +1,19 @@ +#!/bin/bash + +# A wrapper for dmenu to always have it spawn with certain properties +# TODO: Get rid of this script + +source "$HOME/.cache/wal/colors.sh" + +/usr/local/bin/dmenu \ +-fn "JetBrains Mono:size=19:pixelsize=24" \ +-nb "$background" \ +-nf "$foreground" \ +-sb "$color1" \ +-sf "$background" \ +-x "10" \ +-y "10" \ +-z "2860" \ +-h "44" \ +-i + diff --git a/scripts/.local/bin/personal/wrapper/stabbed b/scripts/.local/bin/personal/wrapper/stabbed new file mode 100755 index 0000000..4a14dbf --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/stabbed @@ -0,0 +1,5 @@ +#!/bin/bash + +# A wrapper for st in tabbed, renamed to prevent recursion + +tabbed -c st -w diff --git a/scripts/.local/bin/personal/wrapper/tabura b/scripts/.local/bin/personal/wrapper/tabura new file mode 100755 index 0000000..29f1401 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/tabura @@ -0,0 +1,5 @@ +#!/bin/bash + +# A wrapper for zathura in tabbed, renamed to prevent recursion + +tabbed -c zathura -e diff --git a/scripts/.local/bin/personal/wrapper/xdg-open b/scripts/.local/bin/personal/wrapper/xdg-open new file mode 100755 index 0000000..a5b43d6 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/xdg-open @@ -0,0 +1,18 @@ +#!/bin/sh + +# A wrapper for xdg-open to catch certain cases not caught by mimeapps.list + +case "${1%%:*}" in + http|https) + exec qutebrowser "$1" + ;; + *.pdf) + exec zathura "$1" + ;; + mailto) + exec st -e bash -i -c "mail $1" + ;; + *) + exec /usr/bin/xdg-open "$@" + ;; +esac diff --git a/scripts/.local/bin/personal/zeit b/scripts/.local/bin/personal/zeit deleted file mode 100755 index f31894d..0000000 --- a/scripts/.local/bin/personal/zeit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Don't ask. It's really weird and painful to explain. - -tty-clock -C 3 -f %d.%m.%Y -sc -- cgit v1.2.3