From e9d5df01295a6ea381a0e72b96f4d3555c5e25c2 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Tue, 6 Dec 2022 21:06:39 +0100 Subject: Organize scripts --- scripts/.local/bin/personal/bar/brightness | 4 +- scripts/.local/bin/personal/bar/music | 12 + scripts/.local/bin/personal/bar/mute | 31 +++ scripts/.local/bin/personal/batestimate | 17 -- scripts/.local/bin/personal/compresspdf | 2 + scripts/.local/bin/personal/dayprogress | 6 - scripts/.local/bin/personal/edge2 | 31 --- scripts/.local/bin/personal/edgedetect | 31 --- 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/lfub | 24 -- scripts/.local/bin/personal/mats | 3 +- scripts/.local/bin/personal/mountmenu | 28 --- scripts/.local/bin/personal/music | 12 - scripts/.local/bin/personal/mute | 31 --- scripts/.local/bin/personal/pdfcompress | 4 - scripts/.local/bin/personal/pipes.sh | 385 ----------------------------- scripts/.local/bin/personal/rica | 5 +- scripts/.local/bin/personal/rotdir | 12 - scripts/.local/bin/personal/tabmenu | 25 -- scripts/.local/bin/personal/wally | 2 +- 24 files changed, 510 insertions(+), 612 deletions(-) create mode 100755 scripts/.local/bin/personal/bar/music create mode 100755 scripts/.local/bin/personal/bar/mute delete mode 100755 scripts/.local/bin/personal/batestimate delete mode 100755 scripts/.local/bin/personal/dayprogress delete mode 100755 scripts/.local/bin/personal/edge2 delete mode 100755 scripts/.local/bin/personal/edgedetect create mode 100755 scripts/.local/bin/personal/ext/lfub create mode 100755 scripts/.local/bin/personal/ext/panes create mode 100755 scripts/.local/bin/personal/ext/pipes.sh create mode 100755 scripts/.local/bin/personal/ext/rotdir create mode 100755 scripts/.local/bin/personal/ext/xdg-open delete mode 100755 scripts/.local/bin/personal/lfub delete mode 100755 scripts/.local/bin/personal/mountmenu delete mode 100755 scripts/.local/bin/personal/music delete mode 100755 scripts/.local/bin/personal/mute delete mode 100755 scripts/.local/bin/personal/pdfcompress delete mode 100755 scripts/.local/bin/personal/pipes.sh delete mode 100755 scripts/.local/bin/personal/rotdir delete mode 100755 scripts/.local/bin/personal/tabmenu diff --git a/scripts/.local/bin/personal/bar/brightness b/scripts/.local/bin/personal/bar/brightness index a7dbe73..681c846 100755 --- a/scripts/.local/bin/personal/bar/brightness +++ b/scripts/.local/bin/personal/bar/brightness @@ -4,8 +4,8 @@ # Depends on: bash, brightnessctl # By David Penkowoj, 2021/06/24 -MTR_VALUE=15 -KBD_VALUE=1 +MTR_VALUE=19 +KBD_VALUE=2 SWITCH="$1" diff --git a/scripts/.local/bin/personal/bar/music b/scripts/.local/bin/personal/bar/music new file mode 100755 index 0000000..54104b0 --- /dev/null +++ b/scripts/.local/bin/personal/bar/music @@ -0,0 +1,12 @@ +#!/bin/bash + +STATE="$(mpc | grep -o playing)" +NAME="$(mpc current | xargs -i basename '{}')" +VOLUME="$(mpc volume | awk '{print $2}')" + +if [[ -n "$STATE" ]]; then + echo "MPD Playing: ${NAME%.*} ($VOLUME)" +else + echo "MPD Paused" +fi + diff --git a/scripts/.local/bin/personal/bar/mute b/scripts/.local/bin/personal/bar/mute new file mode 100755 index 0000000..1103c0e --- /dev/null +++ b/scripts/.local/bin/personal/bar/mute @@ -0,0 +1,31 @@ +#!/bin/bash + +SOURCE="alsa_input.usb-R__DE_Microphones_R__DE_NT-USB_Mini_610BAACA-00.mono-fallback" + +if [[ "$1" == "shortstatus" ]]; then + VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)" + + if [[ "$VOLUME" == "0%" ]]; then + echo "OFF" + else + echo "ON" + fi + + exit +fi + +if [[ "$1" == "status" ]]; then + NAME="$(pactl list sources | grep -o Description:.* | sed -n 's/Description: //g;2p')" + VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)" + + echo "$NAME ($VOLUME)" + + exit +fi + +if [[ "$(pactl get-source-volume $SOURCE | grep -o [0-9]*%)" == "0%" ]]; then + pactl set-source-volume "$SOURCE" 70% +else + pactl set-source-volume "$SOURCE" 0% +fi + diff --git a/scripts/.local/bin/personal/batestimate b/scripts/.local/bin/personal/batestimate deleted file mode 100755 index b8d70aa..0000000 --- a/scripts/.local/bin/personal/batestimate +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 - -charge_now_path = "/sys/class/power_supply/BAT0/charge_now" -current_now_path = "/sys/class/power_supply/BAT0/current_now" - -f = open(charge_now_path, "r") -charge_now = int(f.readlines()[0]) -f = open(current_now_path, "r") -current_now = int(f.readlines()[0]) - -ratio = charge_now / current_now * 100 - -hours = ratio / 60 -minutes = ratio % 60 - -print(str(hours) + ":" + str(minutes)) - diff --git a/scripts/.local/bin/personal/compresspdf b/scripts/.local/bin/personal/compresspdf index 8ad1b07..0b9da37 100755 --- a/scripts/.local/bin/personal/compresspdf +++ b/scripts/.local/bin/personal/compresspdf @@ -3,6 +3,8 @@ # PDF Compressor # Dependencies: ghostscript +# Note to self: "prepress" can also be "ebook" + if [[ -e $1 ]]; then gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile="${1}_compressed.pdf" "$1" && printf "done" || printf "error" diff --git a/scripts/.local/bin/personal/dayprogress b/scripts/.local/bin/personal/dayprogress deleted file mode 100755 index f872893..0000000 --- a/scripts/.local/bin/personal/dayprogress +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python3 - -from datetime import datetime - -minute = datetime.now().minute -print(minute / 60 * 100) diff --git a/scripts/.local/bin/personal/edge2 b/scripts/.local/bin/personal/edge2 deleted file mode 100755 index 376bebb..0000000 --- a/scripts/.local/bin/personal/edge2 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/env python - -import sys -import cv2 -import math -import numpy as np -import matplotlib.pyplot as plt - -def correct(): - img = cv2.imread(sys.argv[1]) - rows,cols,ch = img.shape - - pts1 = np.float32([[98, 786],[20, 3268],[1800, 3268],[1798, 850]]) - - ratio=1.6 - cardH=math.sqrt((pts1[2][0]-pts1[1][0])*(pts1[2][0]-pts1[1][0])+(pts1[2][1]-pts1[1][1])*(pts1[2][1]-pts1[1][1])) - cardW=ratio*cardH; - pts2 = np.float32([[pts1[0][0],pts1[0][1]], [pts1[0][0]+cardW, pts1[0][1]], [pts1[0][0]+cardW, pts1[0][1]+cardH], [pts1[0][0], pts1[0][1]+cardH]]) - - M = cv2.getPerspectiveTransform(pts1,pts2) - - offsetSize=500 - transformed = np.zeros((int(cardW+offsetSize), int(cardH+offsetSize)), dtype=np.uint8); - dst = cv2.warpPerspective(img, M, transformed.shape) - - plt.subplot(121),plt.imshow(img),plt.title('Input') - plt.subplot(122),plt.imshow(dst),plt.title('Output') - plt.show() - -if __name__ == "__main__": - correct() diff --git a/scripts/.local/bin/personal/edgedetect b/scripts/.local/bin/personal/edgedetect deleted file mode 100755 index 34d26c8..0000000 --- a/scripts/.local/bin/personal/edgedetect +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/env python3 - -import sys -import cv2 as cv -import numpy as np -import matplotlib.pyplot as plt -from skimage.io import imread, imshow -from skimage.color import rgb2gray -from skimage.feature import match_template, peak_local_max -from skimage import transform - -def detect(): - #img = cv.imread(cv.samples.findFile(sys.argv[1])) - #if img is None: - # sys.exit("Could not read the image.") - #_,img = cv.threshold(img, 128, 255, cv.THRESH_BINARY) - - image= cv.imread(sys.argv[1]) - gray= cv.cvtColor(image, cv.COLOR_BGR2GRAY) - gray= np.float32(gray) - harris_corners= cv.cornerHarris(gray, 3, 3, 0.05) - kernel= np.ones((7,7), np.uint8) - harris_corners= cv.dilate(harris_corners, kernel, iterations= 2) - image[harris_corners > 0.025 * harris_corners.max()]= [255,127,127] - cv.imshow('Harris Corners', image) - cv.waitKey(0) - cv.destroyAllWindows() - - -if __name__ == "__main__": - detect() diff --git a/scripts/.local/bin/personal/ext/lfub b/scripts/.local/bin/personal/ext/lfub new file mode 100755 index 0000000..9012f50 --- /dev/null +++ b/scripts/.local/bin/personal/ext/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/ext/panes b/scripts/.local/bin/personal/ext/panes new file mode 100755 index 0000000..a191de8 --- /dev/null +++ b/scripts/.local/bin/personal/ext/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/ext/pipes.sh b/scripts/.local/bin/personal/ext/pipes.sh new file mode 100755 index 0000000..73346ef --- /dev/null +++ b/scripts/.local/bin/personal/ext/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/ext/rotdir b/scripts/.local/bin/personal/ext/rotdir new file mode 100755 index 0000000..86da6db --- /dev/null +++ b/scripts/.local/bin/personal/ext/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/ext/xdg-open b/scripts/.local/bin/personal/ext/xdg-open new file mode 100755 index 0000000..3136dda --- /dev/null +++ b/scripts/.local/bin/personal/ext/xdg-open @@ -0,0 +1,13 @@ +#!/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/lfub b/scripts/.local/bin/personal/lfub deleted file mode 100755 index 9012f50..0000000 --- a/scripts/.local/bin/personal/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/mats b/scripts/.local/bin/personal/mats index ba299a8..747e1d1 100755 --- a/scripts/.local/bin/personal/mats +++ b/scripts/.local/bin/personal/mats @@ -1,4 +1,5 @@ #!/bin/bash wmname LG3D -exec matlab -r "s = settings;s.matlab.desktop.DisplayScaleFactor.PersonalValue=2;quit" -nodesktop -nosplash +# exec matlab -r "s = settings;s.matlab.desktop.DisplayScaleFactor.PersonalValue=2;quit" -nodesktop -nosplash +matlab -nosplash diff --git a/scripts/.local/bin/personal/mountmenu b/scripts/.local/bin/personal/mountmenu deleted file mode 100755 index 1b5a007..0000000 --- a/scripts/.local/bin/personal/mountmenu +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Colors -BACKGROUND="#1A1A1A" -INACTIVE="#1F1F1F" -ACTIVE="#186673" -TEXT="#FFFFFF" - -# Launching -RESULT="$(echo "$(lsblk -l | awk '$3 == "1" {print $0}' | grep part)" | rofi -no-lazy-grab -dmenu \ --display-drun "Applications :" -drun-display-format "{name}" \ --hide-scrollbar true \ --matching fuzzy \ --bw 0 \ --lines 5 \ --line-padding 15 \ --padding 20 \ --width 50 \ --font "Hack 20" \ --color-enabled true \ --color-window "$BACKGROUND, $BACKGROUND, $BACKGROUND" \ --color-normal "$INACTIVE, $TEXT, $INACTIVE, $ACTIVE, $TEXT" | awk '{print $1}' )" - -mkdir -p /mnt/mount -sudo mount "/dev/$RESULT" /mnt/mount && notify-send "Erfolg" || notify-send "Fehler" - -# I like this font -# -font "Fantasque Sans Mono 20" \ diff --git a/scripts/.local/bin/personal/music b/scripts/.local/bin/personal/music deleted file mode 100755 index 54104b0..0000000 --- a/scripts/.local/bin/personal/music +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -STATE="$(mpc | grep -o playing)" -NAME="$(mpc current | xargs -i basename '{}')" -VOLUME="$(mpc volume | awk '{print $2}')" - -if [[ -n "$STATE" ]]; then - echo "MPD Playing: ${NAME%.*} ($VOLUME)" -else - echo "MPD Paused" -fi - diff --git a/scripts/.local/bin/personal/mute b/scripts/.local/bin/personal/mute deleted file mode 100755 index 1103c0e..0000000 --- a/scripts/.local/bin/personal/mute +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -SOURCE="alsa_input.usb-R__DE_Microphones_R__DE_NT-USB_Mini_610BAACA-00.mono-fallback" - -if [[ "$1" == "shortstatus" ]]; then - VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)" - - if [[ "$VOLUME" == "0%" ]]; then - echo "OFF" - else - echo "ON" - fi - - exit -fi - -if [[ "$1" == "status" ]]; then - NAME="$(pactl list sources | grep -o Description:.* | sed -n 's/Description: //g;2p')" - VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)" - - echo "$NAME ($VOLUME)" - - exit -fi - -if [[ "$(pactl get-source-volume $SOURCE | grep -o [0-9]*%)" == "0%" ]]; then - pactl set-source-volume "$SOURCE" 70% -else - pactl set-source-volume "$SOURCE" 0% -fi - diff --git a/scripts/.local/bin/personal/pdfcompress b/scripts/.local/bin/personal/pdfcompress deleted file mode 100755 index aa972ea..0000000 --- a/scripts/.local/bin/personal/pdfcompress +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="c_$1" "$1" - diff --git a/scripts/.local/bin/personal/pipes.sh b/scripts/.local/bin/personal/pipes.sh deleted file mode 100755 index 73346ef..0000000 --- a/scripts/.local/bin/personal/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/rica b/scripts/.local/bin/personal/rica index 5004785..178f2fc 100755 --- a/scripts/.local/bin/personal/rica +++ b/scripts/.local/bin/personal/rica @@ -36,7 +36,7 @@ def change_zathura(old_colors, new_colors): find_and_replace_config(file_path, old_colors, new_colors) def change_qutebrowser(old_colors, new_colors): - file_path = "/home/me/.config/qutebrowser/config.py" + file_path = "/home/me/.config/qutebrowser/utils.py" find_and_replace_config(file_path, old_colors, new_colors) @@ -49,5 +49,6 @@ relevant = [ ] if __name__ == "__main__": - os.system('xrdb merge "$HOME/.cache/wal/colors.Xresources"') + os.system('xrdb -merge "$HOME/.cache/wal/colors.Xresources"') + os.system('xrdb -merge "$HOME/.Xresources"') replace_color_configs() diff --git a/scripts/.local/bin/personal/rotdir b/scripts/.local/bin/personal/rotdir deleted file mode 100755 index 86da6db..0000000 --- a/scripts/.local/bin/personal/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/tabmenu b/scripts/.local/bin/personal/tabmenu deleted file mode 100755 index 4c0404b..0000000 --- a/scripts/.local/bin/personal/tabmenu +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Colors -BACKGROUND="#1A1A1A" -INACTIVE="#1F1F1F" -ACTIVE="#186673" -TEXT="#FFFFFF" - -# Launching -rofi -no-lazy-grab -show windowcd \ --display-drun "Applications :" -drun-display-format "{name}" \ --hide-scrollbar true \ --matching fuzzy \ --bw 0 \ --lines 5 \ --line-padding 15 \ --padding 20 \ --width 50 \ --font "Hack 20" \ --color-enabled true \ --color-window "$BACKGROUND, $BACKGROUND, $BACKGROUND" \ --color-normal "$INACTIVE, $TEXT, $INACTIVE, $ACTIVE, $TEXT" \ - -# I like this font -# -font "Fantasque Sans Mono 20" \ diff --git a/scripts/.local/bin/personal/wally b/scripts/.local/bin/personal/wally index 91ab90e..22f3f11 100755 --- a/scripts/.local/bin/personal/wally +++ b/scripts/.local/bin/personal/wally @@ -15,7 +15,7 @@ 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" -q -b "#1a1a1a" --saturate "$saturation" + wal -i "$1" -b "#1a1a1a" --saturate "$saturation" echo "Caching wallpaper." cp "$1" "$cachedWallpaperFile" echo "Setting wallpaper." -- cgit v1.2.3