From 8ec89f25e98c83bd348856f767ae2d193583d91a Mon Sep 17 00:00:00 2001 From: davidpkj Date: Sun, 27 Aug 2023 16:36:12 +0200 Subject: Reorganize scripts --- scripts/.local/bin/personal/bar/brightness | 2 +- scripts/.local/bin/personal/bar/mute | 8 +- scripts/.local/bin/personal/bar/network | 10 +- scripts/.local/bin/personal/bar/status | 12 +- scripts/.local/bin/personal/bar/updates | 2 +- scripts/.local/bin/personal/books | 2 +- scripts/.local/bin/personal/compile | 11 +- scripts/.local/bin/personal/dlvideo | 12 ++ scripts/.local/bin/personal/external/helpdesk | 65 ++++++ scripts/.local/bin/personal/external/restream | 263 ++++++++++++++++++++++++ scripts/.local/bin/personal/hackpapier | 3 + scripts/.local/bin/personal/infoboard | 3 - scripts/.local/bin/personal/launcha | 3 + scripts/.local/bin/personal/launchb | 4 + scripts/.local/bin/personal/launchworkingenv | 3 - scripts/.local/bin/personal/musctl | 2 +- scripts/.local/bin/personal/powermenu | 6 +- scripts/.local/bin/personal/reMerge | 44 ++++ scripts/.local/bin/personal/recordscreen | 19 ++ scripts/.local/bin/personal/rica | 46 +---- scripts/.local/bin/personal/rmfc | 4 +- scripts/.local/bin/personal/screenshot | 13 +- scripts/.local/bin/personal/syshealth | 11 +- scripts/.local/bin/personal/tcolorget | 125 +++++++++++ scripts/.local/bin/personal/themes | 6 + scripts/.local/bin/personal/underscoreitall | 11 + scripts/.local/bin/personal/wally | 30 ++- scripts/.local/bin/personal/wrapper/FreeCAD | 1 + scripts/.local/bin/personal/wrapper/anki | 3 + scripts/.local/bin/personal/wrapper/dmenu | 6 +- scripts/.local/bin/personal/wrapper/ebooks | 3 + scripts/.local/bin/personal/wrapper/fcad | 3 + scripts/.local/bin/personal/wrapper/freecad | 1 + scripts/.local/bin/personal/wrapper/gephi | 4 + scripts/.local/bin/personal/wrapper/jlab | 3 + scripts/.local/bin/personal/wrapper/leser | 3 + scripts/.local/bin/personal/wrapper/mscore | 4 + scripts/.local/bin/personal/wrapper/octavia | 3 + scripts/.local/bin/personal/wrapper/pdfunite | 35 ++++ scripts/.local/bin/personal/wrapper/penpot | 7 + scripts/.local/bin/personal/wrapper/phps | 9 + scripts/.local/bin/personal/wrapper/qutebrowser | 3 + scripts/.local/bin/personal/wrapper/sxiv | 112 ++++++++++ scripts/.local/bin/personal/wrapper/xbg | 6 + scripts/.local/bin/personal/wrapper/xdg-open | 21 +- scripts/.local/bin/personal/wrapper/xevs | 4 + 46 files changed, 861 insertions(+), 90 deletions(-) create mode 100755 scripts/.local/bin/personal/dlvideo create mode 100755 scripts/.local/bin/personal/external/helpdesk create mode 100755 scripts/.local/bin/personal/external/restream create mode 100755 scripts/.local/bin/personal/hackpapier delete mode 100755 scripts/.local/bin/personal/infoboard create mode 100755 scripts/.local/bin/personal/launcha create mode 100755 scripts/.local/bin/personal/launchb delete mode 100755 scripts/.local/bin/personal/launchworkingenv create mode 100755 scripts/.local/bin/personal/reMerge create mode 100755 scripts/.local/bin/personal/recordscreen create mode 100755 scripts/.local/bin/personal/tcolorget create mode 100755 scripts/.local/bin/personal/themes create mode 100755 scripts/.local/bin/personal/underscoreitall create mode 120000 scripts/.local/bin/personal/wrapper/FreeCAD create mode 100755 scripts/.local/bin/personal/wrapper/anki create mode 100755 scripts/.local/bin/personal/wrapper/ebooks create mode 100755 scripts/.local/bin/personal/wrapper/fcad create mode 120000 scripts/.local/bin/personal/wrapper/freecad create mode 100755 scripts/.local/bin/personal/wrapper/gephi create mode 100755 scripts/.local/bin/personal/wrapper/jlab create mode 100755 scripts/.local/bin/personal/wrapper/leser create mode 100755 scripts/.local/bin/personal/wrapper/mscore create mode 100755 scripts/.local/bin/personal/wrapper/octavia create mode 100755 scripts/.local/bin/personal/wrapper/pdfunite create mode 100755 scripts/.local/bin/personal/wrapper/penpot create mode 100755 scripts/.local/bin/personal/wrapper/phps create mode 100755 scripts/.local/bin/personal/wrapper/qutebrowser create mode 100755 scripts/.local/bin/personal/wrapper/sxiv create mode 100755 scripts/.local/bin/personal/wrapper/xbg create mode 100755 scripts/.local/bin/personal/wrapper/xevs diff --git a/scripts/.local/bin/personal/bar/brightness b/scripts/.local/bin/personal/bar/brightness index c1a117e..b54de59 100755 --- a/scripts/.local/bin/personal/bar/brightness +++ b/scripts/.local/bin/personal/bar/brightness @@ -7,7 +7,7 @@ # MTR_DEVICE="$MTR_DEVICE" MTR_DEVICE="acpi_video0" KBD_DEVICE="smc::kbd_backlight" -MTR_VALUE=75 +MTR_VALUE=99 KBD_VALUE=0 SWITCH="$1" diff --git a/scripts/.local/bin/personal/bar/mute b/scripts/.local/bin/personal/bar/mute index 834618a..7c987a2 100755 --- a/scripts/.local/bin/personal/bar/mute +++ b/scripts/.local/bin/personal/bar/mute @@ -2,9 +2,10 @@ 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]*%)" +SOURCE="$(pactl get-default-source)" +VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*% | head -n 1)" +if [[ "$1" == "shortstatus" ]]; then if [[ "$VOLUME" == "0%" ]]; then echo "Muted" else @@ -16,14 +17,13 @@ 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 +if [[ "$VOLUME" == "0%" ]]; then pactl set-source-volume "$SOURCE" 70% notify-send -u low "Unmuted" -r 110 else diff --git a/scripts/.local/bin/personal/bar/network b/scripts/.local/bin/personal/bar/network index 915d482..10b156a 100755 --- a/scripts/.local/bin/personal/bar/network +++ b/scripts/.local/bin/personal/bar/network @@ -2,12 +2,8 @@ ssid="$(nmcli device show | grep "GENERAL.CONNECTION" -m 1 | awk '{print $2}')" -if [ -n "$ssid" ]; then - if [ "$ssid" = "--" ]; then - echo "" - else - echo "$ssid" - fi +if [ -n "$ssid" ] && [ "$ssid" != "--" ]; then + echo "$ssid" else - echo "..." + echo "." fi diff --git a/scripts/.local/bin/personal/bar/status b/scripts/.local/bin/personal/bar/status index e6dbbb9..da46bf0 100755 --- a/scripts/.local/bin/personal/bar/status +++ b/scripts/.local/bin/personal/bar/status @@ -1,5 +1,7 @@ #!/bin/dash +# echo 0; exit 0 + # loads colors . ~/.cache/wal/colors.sh @@ -7,13 +9,13 @@ SEPARATOR=" " # default color button use() { - printf "%s^c%s^^b%s^ %s ^b%s^ %s ^b%s^" "$SEPARATOR" "$background" "$color1" "$1" "$color9" "$2" "$background" + printf "%s^c%s^^b%s^ %s ^b%s^ %s ^b%s^" "$SEPARATOR" "$background" "$primary" "$1" "$accent" "$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" "$background" "$1" "$color9" "$color0" "$2" "$background" + printf "%s^c%s^^b%s^ %s ^c%s^^b%s^ %s ^b%s^" "$SEPARATOR" "$primary" "$background" "$1" "$accent" "$background" "$2" "$background" else use "$1" "$2" fi @@ -28,11 +30,11 @@ useif() { # actual string echo "\ -$(useif "" "$(updates read)")\ +$(useif "󰇚" "$(updates read)")\ $(useif "󰍬" "$(mute shortstatus)")\ $(useif "󰕾" "$(volume)")\ -$(useif "說" "$(network)")\ +$(useif "󰒢" "$(network)")\ $(use "󰘚" "$(load) | $(temp)")\ $(use "󱐋" "$(battery)")\ -$(use "" "$(datetime)")\ +$(use "󰃭" "$(datetime)")\ " diff --git a/scripts/.local/bin/personal/bar/updates b/scripts/.local/bin/personal/bar/updates index 9db1bff..dc137d3 100755 --- a/scripts/.local/bin/personal/bar/updates +++ b/scripts/.local/bin/personal/bar/updates @@ -1,6 +1,6 @@ #!/bin/bash -storage=29 +storage=0 if [ "$1" = "read" ]; then if [ "$storage" != "0" ]; then diff --git a/scripts/.local/bin/personal/books b/scripts/.local/bin/personal/books index 11d92c7..d5a8290 100755 --- a/scripts/.local/bin/personal/books +++ b/scripts/.local/bin/personal/books @@ -1,3 +1,3 @@ #!/bin/bash -tabbed -c zathura /home/me/documents/books/lehrbücher/analysis/*.pdf -e +tabbed -c zathura /home/me/documents/books/kuriert/*.pdf -e diff --git a/scripts/.local/bin/personal/compile b/scripts/.local/bin/personal/compile index c5643b8..3f666c1 100755 --- a/scripts/.local/bin/personal/compile +++ b/scripts/.local/bin/personal/compile @@ -38,9 +38,14 @@ MD_TO_PDF() { sed '/^!.*/d' "$1" > "$TMP" && # This enables comments with "!" sed 's/^\\!/!/g' "$TMP" "$TMP" && # This enables escaping with "\!" - 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" + if [[ "${1#*"hackpapier"}" != "$1" ]]; then + pandoc "$TMP" --toc --template "/home/me/documents/templates/hackpapier.latex" -o "$2.pdf" + else + pandoc "$TMP" --template "$HOME/documents/templates/abgaben.latex" -o "$2.pdf" + fi + + # 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 diff --git a/scripts/.local/bin/personal/dlvideo b/scripts/.local/bin/personal/dlvideo new file mode 100755 index 0000000..36ce5e8 --- /dev/null +++ b/scripts/.local/bin/personal/dlvideo @@ -0,0 +1,12 @@ +#!/bin/bash + +if [[ -n "$1" ]]; then + yt-dlp "$1" -i -o "%(title)s.%(ext)s" --cookies "~/.config/cookies.txt" && + exit 0 || + ffmpeg -i "$1" -c:v libx264 -preset slow -crf 22 "$(date +%s).mp4" && + exit 0 || + exit 1 +else + printf "[ Error ] Not enough arguments.\n" + exit 1 +fi diff --git a/scripts/.local/bin/personal/external/helpdesk b/scripts/.local/bin/personal/external/helpdesk new file mode 100755 index 0000000..8ab5aef --- /dev/null +++ b/scripts/.local/bin/personal/external/helpdesk @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# Made for GNU/Linux +# License: MIT + +import sys +import signal +import subprocess + +from datetime import datetime + +fps = 10 +res = "2880x1800" +name = "Analysis 2 Helpdesk" +date = datetime.today().strftime('%a_%d.%m._') +link = "https://uni-luebeck.webex.com/meet/peter.haubold" +file = f"{date}{name.replace(' ', '_')}.mkv" + +web_cmd = f"/usr/bin/brave --app='{link}'" +rec_cmd = f"ffmpeg -y -video_size {res} -framerate {fps} -f x11grab -i :0.0 -f pulse -ac 2 -i default {file}" + + +def log(str, lines=1): + for i in range(1, lines): + print("") + print(str) + + +def end(): + global rec, cisco + + rec.send_signal(signal.SIGINT) + cisco.send_signal(signal.SIGTERM) + subprocess.call("killall CiscoCollabHost", shell=True) + subprocess.call("rm -rf /home/me/Downloads", shell=True) + + +def handler(sig, frame): + log("> Interrupt signal recieved.", 2) + end() + + sys.exit(0) + + +def main(): + global web, rec, cisco + + log(f"> Joining: {name} @ {link} ...", 2) + log("> Session recording starting ...\n", 0) + + cisco = subprocess.Popen("webex", shell=True) + + web = subprocess.Popen(web_cmd, shell=True) + rec = subprocess.Popen(rec_cmd, shell=True) + + signal.signal(signal.SIGINT, handler) + web.wait() + end() + + log(f"> Finished recording session for '{file}'. Finalization may fart.", 3) + + +if __name__ == "__main__": + main() + diff --git a/scripts/.local/bin/personal/external/restream b/scripts/.local/bin/personal/external/restream new file mode 100755 index 0000000..d4a854a --- /dev/null +++ b/scripts/.local/bin/personal/external/restream @@ -0,0 +1,263 @@ +#!/bin/sh + +# Current reStream.sh version +version="1.2.0" + +# default values for arguments +remarkable="remarkable" # remarkable connected through USB +landscape=false # rotate 90 degrees to the right +output_path=- # display output through ffplay +format=- # automatic output format +webcam=false # not to a webcam +hflip=false # horizontal flip webcam +measure_throughput=false # measure how fast data is being transferred +window_title=reStream # stream window title is reStream +video_filters="" # list of ffmpeg filters to apply +unsecure_connection=false # Establish a unsecure connection that is faster + +# loop through arguments and process them +while [ $# -gt 0 ]; do + case "$1" in + -v | --version) + echo "reStream version: v$version" + exit + ;; + -p | --portrait) + landscape=false + shift + ;; + -s | --source) + remarkable="$2" + shift + shift + ;; + -o | --output) + output_path="$2" + shift + shift + ;; + -f | --format) + format="$2" + shift + shift + ;; + -m | --measure) + measure_throughput=true + shift + ;; + -w | --webcam) + webcam=true + format="v4l2" + + # check if there is a modprobed v4l2 loopback device + # use the first cam as default if there is no output_path already + cam_path=$(v4l2-ctl --list-devices \ + | sed -n '/^[^\s]\+platform:v4l2loopback/{n;s/\s*//g;p;q}') + + # fail if there is no such device + if [ -e "$cam_path" ]; then + if [ "$output_path" = "-" ]; then + output_path="$cam_path" + fi + else + echo "Could not find a video loopback device, did you" + echo "sudo modprobe v4l2loopback" + exit 1 + fi + shift + ;; + --mirror) + # do nothing if --webcam is not set + hflip=true + shift + ;; + -t | --title) + window_title="$2" + shift + shift + ;; + -u | --unsecure-connection) + unsecure_connection=true + shift + ;; + -h | --help | *) + echo "Usage: $0 [-p] [-u] [-s ] [-o ] [-f ] [-t ] [-m] [-w] [--hflip]" + echo "Examples:" + echo " $0 # live view in landscape" + echo " $0 -p # live view in portrait" + echo " $0 -s 192.168.0.10 # connect to different IP" + echo " $0 -o remarkable.mp4 # record to a file" + echo " $0 -o udp://dest:1234 -f mpegts # record to a stream" + echo " $0 -w --mirror # write to a webcam (yuv420p + resize + mirror)" + echo " $0 -u # establish a unsecure but faster connection" + exit 1 + ;; + esac +done + +ssh_cmd() { + echo "[SSH]" "$@" >&2 + ssh -o ConnectTimeout=1 \ + -o PasswordAuthentication=no \ + -o PubkeyAcceptedKeyTypes=+ssh-rsa \ + -o HostKeyAlgorithms=+ssh-rsa \ + "root@$remarkable" "$@" +} + +# kill reStream on remarkable at the end. +# shellcheck disable=SC2016 +exit_rm() { + ssh_cmd 'kill $(pidof restream)' +} +trap exit_rm EXIT INT HUP + +# SSH_CONNECTION is a variable on reMarkable => ssh '' instead of ssh "" +# shellcheck disable=SC2016 +remarkable_ip() { + ssh_cmd 'echo $SSH_CONNECTION' | cut -d\ -f3 +} + +# check if we are able to reach the remarkable +if ! ssh_cmd true; then + echo "$remarkable unreachable or you have not set up an ssh key." + echo "If you see a 'Permission denied' error, please visit" + echo "https://github.com/rien/reStream/#installation for instructions." + exit 1 +fi + +rm_version="$(ssh_cmd cat /sys/devices/soc0/machine)" + +case "$rm_version" in + "reMarkable 1.0") + width=1408 + height=1872 + bytes_per_pixel=2 + fb_file="/dev/fb0" + pixel_format="rgb565le" + ;; + "reMarkable 2.0") + if ssh_cmd "[ -f /dev/shm/swtfb.01 ]"; then + width=1404 + height=1872 + bytes_per_pixel=2 + fb_file="/dev/shm/swtfb.01" + pixel_format="rgb565le" + else + width=1872 + height=1404 + bytes_per_pixel=1 + fb_file=":mem:" + pixel_format="gray8" + video_filters="$video_filters,transpose=2" + fi + ;; + *) + echo "Unsupported reMarkable version: $rm_version." + echo "Please visit https://github.com/rien/reStream/ for updates." + exit 1 + ;; +esac + +# technical parameters +loglevel="info" +decompress="lz4 -d" + +# check if lz4 is present on the host +if ! lz4 -V >/dev/null; then + echo "Your host does not have lz4." + echo "Please install it using the instruction in the README:" + echo "https://github.com/rien/reStream/#installation" + exit 1 +fi + +# check if restream binay is present on remarkable +if ssh_cmd "[ ! -f ~/restream ] && [ ! -f /opt/bin/restream ]"; then + echo "The restream binary is not installed on your reMarkable." + echo "Please install it using the instruction in the README:" + echo "https://github.com/rien/reStream/#installation" + exit 1 +fi + +# use pv to measure throughput if desired, else we just pipe through cat +if $measure_throughput; then + if ! pv --version >/dev/null; then + echo "You need to install pv to measure data throughput." + exit 1 + else + loglevel="error" # verbose ffmpeg output interferes with pv + host_passthrough="pv" + fi +else + host_passthrough="cat" +fi + +# store extra ffmpeg arguments in $@ +set -- + +# rotate 90 degrees if landscape=true +$landscape && video_filters="$video_filters,transpose=1" + +# Scale and add padding if we are targeting a webcam because a lot of services +# expect a size of exactly 1280x720 (tested in Firefox, MS Teams, and Skype for +# for business). Send a PR if you can get a higher resolution working. +if $webcam; then + video_filters="$video_filters,format=pix_fmts=yuv420p" + video_filters="$video_filters,scale=-1:720" + video_filters="$video_filters,pad=1280:0:-1:0:#eeeeee" + + # Some applications, eg Zoom and Discord, mirror by default the webcam video + # Restore the correct orientation + $hflip && video_filters="$video_filters,hflip" +fi + +# set each frame presentation time to the time it is received +video_filters="$video_filters,setpts=(RTCTIME - RTCSTART) / (TB * 1000000)" + +set -- "$@" -vf "${video_filters#,}" + +if [ "$output_path" = - ]; then + output_cmd=ffplay + + window_title_option="-window_title $window_title" +else + output_cmd=ffmpeg + + if [ "$format" != - ]; then + set -- "$@" -f "$format" + fi + + set -- "$@" "$output_path" +fi + +set -e # stop if an error occurs + +restream_options="-h $height -w $width -b $bytes_per_pixel -f $fb_file" + +# shellcheck disable=SC2089 +restream_rs="PATH=\"\$PATH:/opt/bin/:.\" restream $restream_options" +if $unsecure_connection; then + listen_port=16789 + ssh_cmd "$restream_rs --listen $listen_port" & + sleep 1 # give some time to restream.rs to start listening + receive_cmd="nc $(remarkable_ip) $listen_port" +else + receive_cmd="ssh_cmd $restream_rs" +fi + +# shellcheck disable=SC2086,SC2090 +$receive_cmd \ + | $decompress \ + | $host_passthrough \ + | ( + "$output_cmd" \ + -vcodec rawvideo \ + -loglevel "$loglevel" \ + -f rawvideo \ + -pixel_format "$pixel_format" \ + -video_size "$width,$height" \ + $window_title_option \ + -i - \ + "$@" \ + ; + kill $$ + ) diff --git a/scripts/.local/bin/personal/hackpapier b/scripts/.local/bin/personal/hackpapier new file mode 100755 index 0000000..1ac6e1e --- /dev/null +++ b/scripts/.local/bin/personal/hackpapier @@ -0,0 +1,3 @@ +#!/bin/bash + +tabbed -c zathura /home/me/documents/zettel/hackpapier/semester2/*.pdf -e diff --git a/scripts/.local/bin/personal/infoboard b/scripts/.local/bin/personal/infoboard deleted file mode 100755 index e2f494a..0000000 --- a/scripts/.local/bin/personal/infoboard +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -notify-send -u low "Not configured" diff --git a/scripts/.local/bin/personal/launcha b/scripts/.local/bin/personal/launcha new file mode 100755 index 0000000..3c7c10e --- /dev/null +++ b/scripts/.local/bin/personal/launcha @@ -0,0 +1,3 @@ +#!/bin/bash + +hackpapier diff --git a/scripts/.local/bin/personal/launchb b/scripts/.local/bin/personal/launchb new file mode 100755 index 0000000..00cfe91 --- /dev/null +++ b/scripts/.local/bin/personal/launchb @@ -0,0 +1,4 @@ +#!/bin/bash + +books + diff --git a/scripts/.local/bin/personal/launchworkingenv b/scripts/.local/bin/personal/launchworkingenv deleted file mode 100755 index 5dcc203..0000000 --- a/scripts/.local/bin/personal/launchworkingenv +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -books diff --git a/scripts/.local/bin/personal/musctl b/scripts/.local/bin/personal/musctl index 4437f37..cca7b8d 100755 --- a/scripts/.local/bin/personal/musctl +++ b/scripts/.local/bin/personal/musctl @@ -12,7 +12,7 @@ notify() { } case "$1" in - "prev") + "previous") mpc -q prev playerctl -s previous ;; diff --git a/scripts/.local/bin/personal/powermenu b/scripts/.local/bin/personal/powermenu index 4f42878..5d4f24a 100755 --- a/scripts/.local/bin/personal/powermenu +++ b/scripts/.local/bin/personal/powermenu @@ -6,10 +6,11 @@ DWM_PID="$(pidof dwm)" OPTION_CANCEL="Cancel" OPTION_SHUTDOWN="Shutdown" OPTION_REBOOT="Restart" +OPTION_SUSPEND="Sleep" OPTION_LOGOUT="Logout" OPTION_LOCK="Lock" -OPTIONS="$OPTION_CANCEL\n$OPTION_SHUTDOWN\n$OPTION_REBOOT\n$OPTION_LOCK\n$OPTION_LOGOUT" +OPTIONS="$OPTION_CANCEL\n$OPTION_SHUTDOWN\n$OPTION_REBOOT\n$OPTION_SUSPEND\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=8')" case $SELECTED in @@ -19,6 +20,9 @@ case $SELECTED in $OPTION_REBOOT) sudo systemctl reboot ;; + $OPTION_SUSPEND) + sudo systemctl suspend + ;; $OPTION_LOCK) sleep 0.2 slock diff --git a/scripts/.local/bin/personal/reMerge b/scripts/.local/bin/personal/reMerge new file mode 100755 index 0000000..654d0a3 --- /dev/null +++ b/scripts/.local/bin/personal/reMerge @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +# Generates a PDF file from slides for easy note taking +# David Penkowoj, 2023-04-17 + +import os +import sys +import getpass +import pikepdf +import subprocess + +file = sys.argv[1] +filename = os.path.splitext(file)[0] +key = getpass.getpass() + +width = 191 +height = width / 4 * 3 +tmpfile = "/tmp/reMergeScaled.pdf" +command = f"cpdf -scale-to-fit \"{width}mm {height}mm\" {file} owner={key} -o {tmpfile}" + +subprocess.run(command, shell=True) + +pdf = pikepdf.Pdf.open("/home/me/documents/remarkable/pdotsa4.pdf") +background = pdf.pages[0] + +overlay_pdf = pikepdf.Pdf.open("/tmp/reMergeScaled.pdf") + +for overlay in overlay_pdf.pages: + pdf.pages.append(background) + + x2 = background.MediaBox[2] + y2 = background.MediaBox[3] + x1 = x2 - (overlay.MediaBox[2] - overlay.MediaBox[0]) + y1 = y2 - (overlay.MediaBox[3] - overlay.MediaBox[1]) + + rect = pikepdf.Rectangle(x1, y1, x2, y2) + + pdf.pages[-1].add_overlay(overlay, rect, shrink=False, expand=False) + +del pdf.pages[0] + +pdf.save(f"{filename}_notes.pdf") +subprocess.run(f"rm -rf {tmpfile}", shell=True) + diff --git a/scripts/.local/bin/personal/recordscreen b/scripts/.local/bin/personal/recordscreen new file mode 100755 index 0000000..e837d01 --- /dev/null +++ b/scripts/.local/bin/personal/recordscreen @@ -0,0 +1,19 @@ +#!/bin/bash + +file="$HOME/recording_$(date +%Y-%m-%d_%H-%M)" + +if [[ -n $1 ]]; then + file="$1" +fi + +ffmpeg \ + -y \ + -video_size 2880x1800 \ + -framerate 10 \ + -f x11grab \ + -i :0.0 \ + -f pulse \ + -ac 2 \ + -i default \ + "$file" + diff --git a/scripts/.local/bin/personal/rica b/scripts/.local/bin/personal/rica index 8a597cc..fe9a2ff 100755 --- a/scripts/.local/bin/personal/rica +++ b/scripts/.local/bin/personal/rica @@ -1,42 +1,18 @@ -#!/usr/bin/env python3 +#!/bin/bash -# A script to update the colors in specific config files for easy ricing. +# A script to update the colors in config files of stubborn programs for easy ricing. # By David Penkowoj, 2022-03-18 -import os +cache="$HOME/.cache/wal" +config="$HOME/.config" -# Get colors and loop over relevant configs -def replace_color_configs(): - with open("/home/me/.cache/wal/oldcolors") as old_color_file: - old_colors = [ color.replace("\n", "") for color in old_color_file.readlines() ] +relevant=("dunst/dunstrc" "zathura/zathurarc" "flameshot/flameshot.ini") - with open("/home/me/.cache/wal/colors") as new_color_file: - new_colors = [ color.replace("\n", "") for color in new_color_file.readlines() ] +xrdb -merge "$HOME/.cache/wal/colors.Xresources" +xrdb -merge "$HOME/.Xresources" - for config in relevant: - find_and_replace_config(config, old_colors, new_colors) +for file in ${relevant[@]}; do + cp "$cache/$(basename $file)" "$config/$file" +done -def find_and_replace_config(file_path, old_colors, new_colors): - with open(file_path, "r") as file: - data = file.read() - - for color in old_colors: - if data.find(color) != -1: - index = old_colors.index(color) - data = data.replace(color, new_colors[index]) - - with open(file_path, "w") as file: - file.write(data) - -relevant = [ - "/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') +killall dunst diff --git a/scripts/.local/bin/personal/rmfc b/scripts/.local/bin/personal/rmfc index 7ad13cb..47410c9 100755 --- a/scripts/.local/bin/personal/rmfc +++ b/scripts/.local/bin/personal/rmfc @@ -2,7 +2,7 @@ REMOTE="http://rmfc.davidpenkowoj.de" -if [[ "$1" = "-auth" ]]; then +if [[ "$1" = "--auth" || "$1" = "-a" ]]; then xdg-open "$REMOTE/generatecode" RMAPI_HOST="$REMOTE:3000" rmapi exit 0 @@ -12,7 +12,7 @@ REMOTE_FILE="$1" LOCAL_FILE="$(basename "$1")" CONFIG_DIR="$HOME/documents/remarkable/rm2pdf" -RMAPI_HOST="$REMOTE/" rmapi -ni get "$REMOTE_FILE" +RMAPI_HOST="$REMOTE/" rmapi -ni get "$REMOTE_FILE" FETCH_STATUS="$?" if [[ -e "$LOCAL_FILE.zip" && "$FETCH_STATUS" = "0" ]]; then diff --git a/scripts/.local/bin/personal/screenshot b/scripts/.local/bin/personal/screenshot index 594340b..937a023 100755 --- a/scripts/.local/bin/personal/screenshot +++ b/scripts/.local/bin/personal/screenshot @@ -1,14 +1,23 @@ #!/bin/bash +directory="$HOME/images/screenshots" +file="$directory/$(date +%F_%s).jpg" + notify() { notify-send "Screenshot saved" "images/screenshots/$(date +%F_%H-%M)" } case "$1" in "full") - flameshot full -p "$HOME/images/screenshots" && notify ;; + flameshot full -r > "$file" && notify ;; "select") - flameshot gui -p "$HOME/images/screenshots" && notify ;; + flameshot gui -r > "$file" + if [[ "$(stat $file | grep 'Size' | awk '{print $2}')" == "0" ]]; then + rm "$file" + else + notify + fi + ;; *) notify-send "Error" "Couldn't save screenshot" ;; esac diff --git a/scripts/.local/bin/personal/syshealth b/scripts/.local/bin/personal/syshealth index b60b122..48dcfa4 100755 --- a/scripts/.local/bin/personal/syshealth +++ b/scripts/.local/bin/personal/syshealth @@ -3,6 +3,7 @@ # NOTE: This script is run by cron periodically export XDG_RUNTIME_DIR="/run/user/$(id -u)" +export DISPLAY=":0" acpi_report="$(acpi | grep -v unavailable | head -n 1)" sensors_report="$(sensors | grep "Package id 0:")" @@ -12,17 +13,17 @@ 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") +battery_message=("Warning:" "Battery VOLTAGE 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 + /usr/local/bin/herbe " ${battery_message[0]} ${battery_message[1]}" & # 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 + /usr/local/bin/herbe " ${battery_message[0]} ${battery_message[1]}" & # espeak "${battery_message[0]}${battery_message[1]}" fi fi @@ -32,7 +33,7 @@ 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 + /usr/local/bin/herbe " ${temperature_message[0]} ${temperature_message[1]}" & # espeak "${temperature_message[0]}${temperature_message[1]}" fi diff --git a/scripts/.local/bin/personal/tcolorget b/scripts/.local/bin/personal/tcolorget new file mode 100755 index 0000000..e3a478a --- /dev/null +++ b/scripts/.local/bin/personal/tcolorget @@ -0,0 +1,125 @@ +#!/usr/bin/env python + +# A script to generate a color palette from an image which still complies with the +# general terminal colors (i.e. red remains red). +# +# Author: David 'davidpkj' Penkowoj <davidpenkow1@gmail.com> +# Version: 0.1.0 +# License: EUPL v. 1.2 @ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 + +from PIL import Image +from colour import Color + +import sys +import math +import colorz as clz +import seaborn as sns +import matplotlib.pyplot as plt + +# Rotate hue and saturation to get other colors +def rotate(input): + # TODO: instead of rotation, maybe calculate deviation from standard value (i.e. hue 60, sat 50) + # and then apply the same deviation to all standard colors + # TODO: also do something about these arbitrary factors + result = [] + iterations = 6 + sat_factor = -0.1 + hue_factor = 1 / iterations + + for i in range(iterations): + _hue = input.hue + _sat = input.saturation + _lum = input.luminance + + _hue = _hue + i * hue_factor + _hue = _hue - math.floor(_hue) + + _newsat = _sat + abs(i * sat_factor) + + if _newsat <= 1 and _newsat >= 0: + _sat = _newsat + + result.append(Color(hsl=(_hue, _sat, _lum))) + + return sorted(result, key=lambda x: x.hue) + +# Get the distance between two numbers (context: hue) +def get_distance(color, target): + return abs(color.hue - target) + +# Returns the color which is closes in hue to the given value +def select_nearest(value, colors): + target = value / 360 + color = colors[0] + distance = get_distance(color, target) + + for c in colors: + new_distance = get_distance(c, target) + + if new_distance < distance: + color = c + distance = new_distance + + # NOTE: special case for red, since can be numerically closer to + # 0° or 360° (1) but not the other. not nice but works + if target == 0: + new_color, new_distance = select_nearest(360, colors) + + if new_distance < distance: + color = new_color + + return color, distance + +# Show a palette +def show_palette(colors): + sns.palplot(sns.color_palette(colors)) + plt.show() + +# Save the original image with the attached palette back to disk. +def save_image(colors, path): + palette_size = 30 + input = Image.open(path) + colors_len = len(colors) + + output = Image.new("RGB", (input.size[0], input.size[1] + palette_size), (0, 0, 0)) + p2 = (input.size[0], input.size[1] + palette_size) + + # Attaches the colors at the bottom of the image + for i in range(colors_len): + p1 = (round(input.size[0] / colors_len) * i, input.size[1]) + + output.paste(colors[i], [p1[0], p1[1], p2[0], p2[1]]) + output.paste(input) + + # output.save("output.png") + output.show() + +def main(file): + # NOTE: The arguments to this function were stolen from the library's internal code. + colorz_tuple = clz.colorz(file, 1, 170, 200, 50)[0][1] + normalized_tuple = (colorz_tuple[0] / 256, colorz_tuple[1] / 256, colorz_tuple[2] / 256) + input_color = Color(rgb=normalized_tuple) + colors = rotate(input_color) + + terminal_colors = {"red": 0, "green": 120, "yellow": 60, "blue": 240, "magenta": 300, "cyan": 180} + + for key in terminal_colors: + color, _= select_nearest(terminal_colors[key], colors) + terminal_colors[key] = color.hex + + # Formulate a propper list of colors + palette = list(terminal_colors.values()) + palette.insert(0, "#1a1a1a") # my favorite constant black + palette.append("#efefef") # my favorite constant white + + return palette, input_color + +if __name__ == "__main__": + path = sys.argv[1] + file = open(path, "rb") + + palette, dominant_color = main(file) + + save_image(palette, path) + print(dominant_color) + diff --git a/scripts/.local/bin/personal/themes b/scripts/.local/bin/personal/themes new file mode 100755 index 0000000..1bce482 --- /dev/null +++ b/scripts/.local/bin/personal/themes @@ -0,0 +1,6 @@ +#!/bin/bash + +dir="$HOME/.config/wal/colorschemes/dark" +theme=$(ls $dir | dmenu) + +wally "$dir/$theme" diff --git a/scripts/.local/bin/personal/underscoreitall b/scripts/.local/bin/personal/underscoreitall new file mode 100755 index 0000000..91ee620 --- /dev/null +++ b/scripts/.local/bin/personal/underscoreitall @@ -0,0 +1,11 @@ +#!/bin/bash + +name="$(echo "$1" | sed 's/ /_/g')" + +if [[ -e "$name" || ! -e "$1" ]]; then + printf "either output file exists or input file doesnt exist" || mv $f $1 + exit 1 +else + mv "$1" "$name" +fi + diff --git a/scripts/.local/bin/personal/wally b/scripts/.local/bin/personal/wally index d05bfad..b733873 100755 --- a/scripts/.local/bin/personal/wally +++ b/scripts/.local/bin/personal/wally @@ -6,27 +6,48 @@ # Usage: wally {path to image} [backend] [saturation value] -backend="colorz" +light_theme="no" + +backend="wal" # colorz saturation="0.5" wallpaperDir="$HOME/images/wallpapers" -cachedWallpaperFile="$HOME/.config/wallpaper" +cachedWallpaperFile="$HOME/.config/wallpaper" # TODO: symlink to dotfiles + +if [[ "$light_theme" = "yes" ]]; then + saturation="0.7" +fi 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" --cols16 - # wal -i "$1" -b "#ffffff" --saturate "$saturation" --cols16 -l + if [[ "$light_theme" = "yes" ]]; then + wal -i "$1" -b "#ffffff" --saturate "$saturation" --backend "$backend" --cols16 -l + else + wal -i "$1" -b "#1a1a1a" --saturate "$saturation" --backend "$backend" --cols16 + fi + echo "Caching wallpaper." cp "$1" "$cachedWallpaperFile" + echo "Setting wallpaper." feh --bg-fill "$cachedWallpaperFile" + echo "Updating various software with rica." rica + echo "Refreshing window manager." xdotool key Super_L+r } +if [[ $1 == *.json ]]; then + wal --theme "$1" + rica + xdotool key Super_L+r + exit 0 +fi + if [[ -n "$3" ]]; then echo "Got saturation value '$3'." saturation="$3" @@ -54,4 +75,3 @@ else echo "No image found." fi fi - diff --git a/scripts/.local/bin/personal/wrapper/FreeCAD b/scripts/.local/bin/personal/wrapper/FreeCAD new file mode 120000 index 0000000..5b3d27a --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/FreeCAD @@ -0,0 +1 @@ +fcad \ No newline at end of file diff --git a/scripts/.local/bin/personal/wrapper/anki b/scripts/.local/bin/personal/wrapper/anki new file mode 100755 index 0000000..5a63534 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/anki @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/anki diff --git a/scripts/.local/bin/personal/wrapper/dmenu b/scripts/.local/bin/personal/wrapper/dmenu index ef03598..2994845 100755 --- a/scripts/.local/bin/personal/wrapper/dmenu +++ b/scripts/.local/bin/personal/wrapper/dmenu @@ -3,13 +3,13 @@ # A wrapper for dmenu to always have it spawn with certain properties # TODO: Get rid of this script -source "$HOME/.cache/wal/colors.sh" +source "/home/me/.cache/wal/colors.sh" /usr/local/bin/dmenu \ -fn "JetBrains Mono:size=19:pixelsize=24" \ -nb "$background" \ -nf "$foreground" \ --sb "$color1" \ +-sb "$primary" \ -sf "$background" \ -x "10" \ -y "10" \ @@ -17,3 +17,5 @@ source "$HOME/.cache/wal/colors.sh" -h "44" \ -i +# -m 0 \ + diff --git a/scripts/.local/bin/personal/wrapper/ebooks b/scripts/.local/bin/personal/wrapper/ebooks new file mode 100755 index 0000000..8c027bb --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/ebooks @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/calibre "$@" diff --git a/scripts/.local/bin/personal/wrapper/fcad b/scripts/.local/bin/personal/wrapper/fcad new file mode 100755 index 0000000..c3f9450 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/fcad @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/FreeCAD "$@" diff --git a/scripts/.local/bin/personal/wrapper/freecad b/scripts/.local/bin/personal/wrapper/freecad new file mode 120000 index 0000000..5b3d27a --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/freecad @@ -0,0 +1 @@ +fcad \ No newline at end of file diff --git a/scripts/.local/bin/personal/wrapper/gephi b/scripts/.local/bin/personal/wrapper/gephi new file mode 100755 index 0000000..8e7ed21 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/gephi @@ -0,0 +1,4 @@ +#!/bin/dash + +/usr/bin/gephi -J-Dsun.java2d.uiScale=2 + diff --git a/scripts/.local/bin/personal/wrapper/jlab b/scripts/.local/bin/personal/wrapper/jlab new file mode 100755 index 0000000..eecd0e0 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/jlab @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/brave --app=http://localhost:9999/?token=archbook diff --git a/scripts/.local/bin/personal/wrapper/leser b/scripts/.local/bin/personal/wrapper/leser new file mode 100755 index 0000000..6f45b55 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/leser @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/less -c -s -M +Gg diff --git a/scripts/.local/bin/personal/wrapper/mscore b/scripts/.local/bin/personal/wrapper/mscore new file mode 100755 index 0000000..c446a28 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/mscore @@ -0,0 +1,4 @@ +#!/bin/dash + +/usr/bin/mscore +rm -rf "$HOME/Documents" diff --git a/scripts/.local/bin/personal/wrapper/octavia b/scripts/.local/bin/personal/wrapper/octavia new file mode 100755 index 0000000..83f34b9 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/octavia @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/octave --gui "$@" diff --git a/scripts/.local/bin/personal/wrapper/pdfunite b/scripts/.local/bin/personal/wrapper/pdfunite new file mode 100755 index 0000000..87f368a --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/pdfunite @@ -0,0 +1,35 @@ +#!/bin/env python + +import sys +import subprocess + +def main(): + output = "pdfunite.pdf" + files = [] + + for i, arg in zip(range(len(sys.argv)), sys.argv): + if i == 0: + continue + + if arg == "-o": + # output = '_'.join(sys.argv[i + 1 : len(sys.argv)]) + output = str(sys.argv[i + 1]) + continue + if not arg.startswith("-") and sys.argv[i - 1] != "-o": + files.append(arg) + + convert_to_pdf = ["jpg", "jpeg", "png"] + + for i, file in zip(range(len(files)), files): + for extension in convert_to_pdf: + if file.endswith(extension): + tmpfile = f"/tmp/{file.replace('/', '_')}.pdf" + subprocess.run(["convert", file, tmpfile]) + files[i] = tmpfile + + cmd_str = f"/usr/bin/pdfunite {' '.join(files)} {output}" + subprocess.run(cmd_str, shell=True) + +if __name__ == "__main__": + main() + diff --git a/scripts/.local/bin/personal/wrapper/penpot b/scripts/.local/bin/personal/wrapper/penpot new file mode 100755 index 0000000..a4124d6 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/penpot @@ -0,0 +1,7 @@ +#!/bin/bash + +cd "$HOME/software/penpot/" && +docker compose -p penpot -f docker-compose.yaml up -d & + +/usr/bin/brave --app='http://localhost:9001' && +docker compose -p penpot -f docker-compose.yaml down diff --git a/scripts/.local/bin/personal/wrapper/phps b/scripts/.local/bin/personal/wrapper/phps new file mode 100755 index 0000000..5567837 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/phps @@ -0,0 +1,9 @@ +#!/bin/bash + +if [[ -n "$1" ]]; then + echo "php -S localhost:1337 -c $1" + php -S localhost:1337 -c "$1" +else + echo "php -S localhost:1337" + php -S localhost:1337 +fi diff --git a/scripts/.local/bin/personal/wrapper/qutebrowser b/scripts/.local/bin/personal/wrapper/qutebrowser new file mode 100755 index 0000000..d24f209 --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/qutebrowser @@ -0,0 +1,3 @@ +#!/bin/dash + +/usr/bin/qutebrowser "$@" diff --git a/scripts/.local/bin/personal/wrapper/sxiv b/scripts/.local/bin/personal/wrapper/sxiv new file mode 100755 index 0000000..36d120c --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/sxiv @@ -0,0 +1,112 @@ +#!/bin/dash + +# nsxiv pipe +# +# tmpfile="${TMPDIR:-/tmp}/nsxiv_pipe_$$" +# trap 'rm -f -- $tmpfile' EXIT +# +# if [ "$#" -eq 0 ]; then +# if [ -t 0 ]; then +# echo "nsxiv-pipe: No arguments provided" >&2; exit 1 +# else +# # Consume stdin and put it in the temporal file +# cat > "$tmpfile" +# fi +# fi +# +# for arg in "$@"; do +# # if it's a pipe then drain it to $tmpfile +# [ -p "$arg" ] && cat "$arg" > "$tmpfile" +# done +# +# if [ -s "$tmpfile" ]; then +# nsxiv -q "$@" "$tmpfile" # -q to silence warnings +# else +# nsxiv "$@" # fallback +# fi + +# nsxiv rifle +# +# TMPDIR="${TMPDIR:-/tmp}" +# tmp="$TMPDIR/nsxiv_rifle_$$" +# +# is_img_extension() { +# grep -iE '\.(jpe?g|png|gif|svg|webp|tiff|heif|avif|ico|bmp)$' +# } +# +# listfiles() { +# find -L "$1" -maxdepth 1 -type f -print | +# is_img_extension | sort | tee "$tmp" +# } +# +# open_img() { +# file="$1"; shift; +# # only go through listfiles() if the file has a valid img extension +# if echo "$file" | is_img_extension >/dev/null 2>&1; then +# trap 'rm -f $tmp' EXIT +# count="$(listfiles "///${file%/*}" | grep -nF "$file")" +# fi +# if [ -n "$count" ]; then +# nsxiv -i -n "${count%%:*}" "$@" -- < "$tmp" +# else +# # fallback incase file didn't have a valid extension, or we couldn't +# # find it inside the list +# nsxiv "$@" -- "$file" +# fi +# } +# +# uri2path() { +# python3 - "$@" <<'___HEREDOC' +# from urllib.parse import unquote, urlparse +# from sys import argv +# for arg in argv[1:]: +# print(unquote(urlparse(arg).path)) +# ___HEREDOC +# } +# +# [ "$1" = '--' ] && shift +# case "$1" in +# "") echo "Usage: ${0##*/} PICTURES" >&2; exit 1 ;; +# /*) open_img "$1" ;; +# "~"/*) open_img "$HOME/${1#"~"/}" ;; +# file:///*) open_img "$(uri2path "$1")" ;; +# trash:///*) +# trash_dir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash/files" +# open_img "${trash_dir}$(uri2path "$1")" -N "nsxiv_trash" +# ;; +# *) open_img "$PWD/$1" ;; +# esac + +# nsxiv url +# cache_dir="${TMPDIR:-/tmp}/nsxiv" +# +# die() { +# [ -n "$1" ] && printf '%s\n' "$*" >&2; +# exit 1 +# } +# +# cleanup() { +# rm -f -- "$cache_dir"/* +# } +# +# get_image() ( +# cd "$cache_dir" && curl -sSLO "$1" +# ) +# +# ### main ### +# +# [ -z "$1" ] && die "No arguments given" +# trap cleanup EXIT +# [ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die +# while [ -n "$1" ]; do +# case "$1" in +# *://*.*) get_image "$1" ;; +# *) echo "Invalid url: $1" >&2 ;; +# esac +# shift +# done +# +# [ "$(find "$cache_dir" -type f -print | wc -l)" -ne 0 ] && +# nsxiv -p "$cache_dir" + +nsxiv diff --git a/scripts/.local/bin/personal/wrapper/xbg b/scripts/.local/bin/personal/wrapper/xbg new file mode 100755 index 0000000..992980b --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/xbg @@ -0,0 +1,6 @@ +#!/bin/dash + +file="$HOME/.config/wallpaper" + +cp "$1" "$file" +/usr/bin/feh --bg-scale --no-fehbg "$file" diff --git a/scripts/.local/bin/personal/wrapper/xdg-open b/scripts/.local/bin/personal/wrapper/xdg-open index a5b43d6..372bbca 100755 --- a/scripts/.local/bin/personal/wrapper/xdg-open +++ b/scripts/.local/bin/personal/wrapper/xdg-open @@ -3,16 +3,19 @@ # A wrapper for xdg-open to catch certain cases not caught by mimeapps.list case "${1%%:*}" in - http|https) - exec qutebrowser "$1" - ;; + http|https|*.html) + exec qutebrowser "$1" + ;; + *.FCStd) + exec freecad "$1" + ;; *.pdf) exec zathura "$1" ;; - mailto) - exec st -e bash -i -c "mail $1" - ;; - *) - exec /usr/bin/xdg-open "$@" - ;; + mailto) + exec st -e bash -i -c "mail $1" + ;; + *) + exec /usr/bin/xdg-open "$@" + ;; esac diff --git a/scripts/.local/bin/personal/wrapper/xevs b/scripts/.local/bin/personal/wrapper/xevs new file mode 100755 index 0000000..68dee0f --- /dev/null +++ b/scripts/.local/bin/personal/wrapper/xevs @@ -0,0 +1,4 @@ +#!/bin/bash + +xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }' + -- cgit v1.2.3