diff options
author | davidpkj <davidpenkow1@gmail.com> | 2023-03-15 14:09:28 +0100 |
---|---|---|
committer | davidpkj <davidpenkow1@gmail.com> | 2023-03-15 14:09:28 +0100 |
commit | 08a332d0daa13e52e4c8ae9bf2dbcb6408041a34 (patch) | |
tree | b75fbf58009572ed8edeb81452276ff6d5d66ec8 /scripts/.local/bin | |
parent | 2c71b057b66f817ca66b3a16eba901a9d214a3cb (diff) |
Cleaned up some scripts
Diffstat (limited to 'scripts/.local/bin')
50 files changed, 386 insertions, 390 deletions
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/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/extract b/scripts/.local/bin/personal/external/extract index b51c413..082136b 100755 --- a/scripts/.local/bin/personal/extract +++ b/scripts/.local/bin/personal/external/extract @@ -16,7 +16,7 @@ if [ -f $1 ] ; then *.deb) ar x $1 ;; *.tar.xz) tar xf $1 ;; *.tar.zst) tar xf $1 ;; - *) echo "'$1' cannot be extracted via ex()" ;; + *) echo "'$1' cannot be extracted" ;; esac else echo "'$1' is not a valid file" diff --git a/scripts/.local/bin/personal/ext/lfub b/scripts/.local/bin/personal/external/lfub index 9012f50..9012f50 100755 --- a/scripts/.local/bin/personal/ext/lfub +++ b/scripts/.local/bin/personal/external/lfub 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/ext/panes b/scripts/.local/bin/personal/external/panes index a191de8..a191de8 100755 --- a/scripts/.local/bin/personal/ext/panes +++ b/scripts/.local/bin/personal/external/panes diff --git a/scripts/.local/bin/personal/ext/pipes.sh b/scripts/.local/bin/personal/external/pipes.sh index 73346ef..73346ef 100755 --- a/scripts/.local/bin/personal/ext/pipes.sh +++ b/scripts/.local/bin/personal/external/pipes.sh diff --git a/scripts/.local/bin/personal/ext/rotdir b/scripts/.local/bin/personal/external/rotdir index 86da6db..86da6db 100755 --- a/scripts/.local/bin/personal/ext/rotdir +++ b/scripts/.local/bin/personal/external/rotdir 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 |