From 6e3a1f376fbef9d0f6f8c72d6b22ff1d40e812ed Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 28 Apr 2023 02:30:33 +0100 Subject: movement --- .local/bin/rupload | 91 ----------------------------------------------- .local/bin/rws | 99 ---------------------------------------------------- .local/bin/status.sh | 52 --------------------------- .local/bin/ud | 49 -------------------------- bin/rupload | 91 +++++++++++++++++++++++++++++++++++++++++++++++ bin/rws | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/status.sh | 52 +++++++++++++++++++++++++++ bin/ud | 49 ++++++++++++++++++++++++++ 8 files changed, 291 insertions(+), 291 deletions(-) delete mode 100755 .local/bin/rupload delete mode 100755 .local/bin/rws delete mode 100755 .local/bin/status.sh delete mode 100755 .local/bin/ud create mode 100755 bin/rupload create mode 100755 bin/rws create mode 100755 bin/status.sh create mode 100755 bin/ud diff --git a/.local/bin/rupload b/.local/bin/rupload deleted file mode 100755 index c414b68..0000000 --- a/.local/bin/rupload +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -if [ $# -eq 0 ]; then - printf '%s\n' "usage: $0 [-n] [-p] [-x EXT | -r NAME | -R] FILENAME" >&2 - printf '\t%s\n' "-n: dry run (don't actually upload anything)" >&2 - printf '\t%s\n' "-p: print uploaded url instead of copying to clipboard and notifying" >&2 - printf '\t%s\n' "-x EXT: set extension to EXT on uploaded filename" >&2 - printf '\t%s\n' "-r NAME: set remote name to NAME including extension" >&2 - printf '\t%s\n' "-R: set remote name to basename of FILENAME" >&2 - exit 1 -fi - -dry_run=0 -samename=0 -printurl=0 -override_rname= -while [ $# -gt 1 ]; do - if [ "$1" = "-x" ]; then - override_ext=".$2" - shift 2 - elif [ "$1" = "-n" ]; then - dry_run=1 - shift - elif [ "$1" = "-p" ]; then - printurl=1 - shift - elif [ "$1" = "-r" ]; then - override_rname="$2" - shift 2 - elif [ "$1" = "-R" ]; then - samename=1 - shift - else - printf "%s: unrecognized argument %s\n" "$0" "$1" >&2 - exit 2 - fi -done - -if [ ! -f "$1" ]; then - printf %s "$1: file does not exist" >&2 - exit 1 -fi - -if [ "$samename" -eq 1 ]; then - override_rname="$(basename "$1")" -fi - -REMOTE="do" -URLBASE="https://ubq323.website/files/" -REMOTEDIR="/srv/web/ubq/files/" - -ext="${1#*.}" -if [ "$ext" = "$1" ]; then - ext='.file' - bname="$(basename "$1")" -else - ext=".$ext" - bname="$(basename "$1" "$ext")" -fi -ext=${override_ext:-$ext} - -rbname="$(md5sum "$1"|cut -d' ' -f1|tr 'a-z' 'A-Z'|basenc -d --base16|basenc --base64url|head -c8)" -rname="${override_rname:-$rbname$ext}" - -exists_already() { - ssh "$REMOTE" stat "$REMOTEDIR$1" 2>/dev/null >/dev/null - return $? -} - -while exists_already "$rname"; do - printf "%s exists already\n" "$rname" >&2 - rname="_$rname" -done - -printf 'uploading to %s\n' "$rname" >&2 -if [ "$dry_run" -eq 1 ]; then - echo dryrun, not uploading anything - exit 0 -fi - -scp -q "$1" "${REMOTE}:$REMOTEDIR$rname" -ssh "$REMOTE" chmod a+r "$REMOTEDIR$rname" - -url="$URLBASE$rname" -if [ "$printurl" -eq 0 ]; then - printf %s "$url" | wl-copy - notify-send 'copied url to clipboard' "$url" -else - printf '%s\n' "$url" -fi - diff --git a/.local/bin/rws b/.local/bin/rws deleted file mode 100755 index 7041e8c..0000000 --- a/.local/bin/rws +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh - -# rebecca workspace -# -# source this from your shell rc file -# and also start rws -listen when you start sway - - -WSD=$XDG_RUNTIME_DIR/ws -mkdir -p $WSD - - - -wslist () { - # list workspaces, most-recently-used first - swaymsg -t get_workspaces | jq -rc '.[] | .name' | while read wsn; do - wsp=$WSD/"$(printf %s "$wsn" | base64)" - dt="$(stat -c '%Y' $wsp 2>/dev/null)" - if [ $? -eq 1 ]; then - dt=1 - fi - printf "%s\t%s\n" "$dt" "$wsn" - done | sort -nr | cut -f2- -} - -_escape() { - printf %s "$1" | sed -e 's*\\*\\\\*g' -e 's*"*\\"*g' -} - -workin () { - # cds to the given directory, then moves focused window to workspace - # with that name - if [ ! -d "$1" ]; then - printf "not a directory\n" >&2 - return 1 - else - cd "$1" - dirname="$(_escape "$(apwd)")" - swaymsg "move container to workspace \"$dirname\"" - swaymsg "workspace \"$dirname\"" - fi -} - - -curws () { - # prints name of current workspace - swaymsg -t get_workspaces \ - | jq -rc '.[] | select(.focused==true) | .name' -} -gowork() { - # cds to working directory for current workspace - d="$(curws|sed -e "s*^~*$HOME*")" - if [ -d "$d" ]; then - cd "$d" || return 1 - fi -} -renws () { - # renames current ws to current working dir - swaymsg "rename workspace to $(apwd)" -} - -queryws () { - # uses bmenu to prompt for a workspace name, then switches to that workspace - # or if -m given, moves focused window to that workspace instead - wsn="$(wslist | bemenu -p workspace -l100 --fn 'Iosevka Fixed 16' --tf '#df73ff' --hf '#df73ff' --hb '#333333')" - [ -z "$wsn" ] && return - - if [ "$1" = "-m" ]; then - swaymsg "move container to workspace \"$(_escape "$wsn")\"" - else - swaymsg "workspace \"$(_escape "$wsn")\"" - fi -} - - -_onswitch () { - wsb=$(printf %s "$1" | base64) - touch ${WSD}/$wsb -} -# run rws -listen to listen for workspace changes, -# and keep track of that -if [ "$1" = "-listen" ]; then - swaymsg -rmt subscribe '[ "workspace" ]' | while read line; do - wsn="$(printf %s "$line" | jq -rc '.current.name')" - printf "%s\n" "$wsn" - _onswitch "$wsn" - done -fi - -# rws -queryws does the same thing as queryws -# because it needs to be runnable from sway cfg in order to keybind something for it -if [ "$1" = "-queryws" ]; then - shift - queryws $@ -fi - - - - diff --git a/.local/bin/status.sh b/.local/bin/status.sh deleted file mode 100755 index 5bd9e4c..0000000 --- a/.local/bin/status.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -puts () { - printf %s "$1" -} - -escape () { - printf %s "$1" | sed -e 's*\\*\\\\*g' -e 's!"!\\"!g' -} - -block_basic () { - printf '{"full_text":"%s"},' "$1" -} -block_color () { - printf '{"full_text":"%s","color":"%s"},' "$1" "$2" -} - -BDIR=/sys/class/power_supply/BAT0 - -# header -printf '%s\n' '{"version":1}' -puts '[' - -while true; do - puts '[' - - volinfo="$(amixer get Master | grep 'Mono:')" - vol_level="$(printf %s "$volinfo" | awk -F'[][]' '{print $2}')" - vol_enabled="$(printf %s "$volinfo" | awk -F'[][]' '{print $6}')" - color="#ffffff"; bl=""; br="" - [ "$vol_enabled" = "off" ] && { color="#ffff00"; bl="("; br=")"; } - block_color "vol $bl$vol_level$br" "$color" - - bat_status="$(cat $BDIR/status | tr 'a-z' 'A-Z' | head -c 3)" - bat_level="$(cat $BDIR/capacity)" - color="#ffffff" - if [ "$bat_level" -le 10 ]; then - color="#ff0000" - elif [ "$bat_level" -le 25 ]; then - color="#ffff00" - fi - block_color "$bat_status $bat_level%" "$color" - - date="$(date +'%a %Y-%m-%d %H:%M:%S')" - block_basic "$date" - - - puts '],' - sleep 1 - -done - diff --git a/.local/bin/ud b/.local/bin/ud deleted file mode 100755 index a1a50ac..0000000 --- a/.local/bin/ud +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 - -# unidump version 0.1.1 -# made by ubq323 in the year 2021 -# please use this software for GOOD, not for EVIL - -import unicodedata -import sys - -uniquify = True -arg="" -args = sys.argv[1:] -while len(args) > 0: - arg = args.pop(0) - if arg[0] != '-' or arg == "--": - break - if arg == "-a": - uniquify = False - arg = "" - - -s = arg+" ".join(args) - -if len(s) == 0: - s = sys.stdin.read() - -def row(c): - try: - name = unicodedata.name(c).rjust(50) - except ValueError: - name = "?"*50 - - number = ("U+"+hex(ord(c))[2:].zfill(4)).rjust(7).upper() - - to_c = c - if c == '\n': - to_c = ' ' - - - - return f"{to_c} | {unicodedata.category(c)} | {name} | {number}" - -seen = set() -for c in s: - if uniquify: - if c in seen: - continue - seen.add(c) - print(row(c)) diff --git a/bin/rupload b/bin/rupload new file mode 100755 index 0000000..c414b68 --- /dev/null +++ b/bin/rupload @@ -0,0 +1,91 @@ +#!/bin/sh + +if [ $# -eq 0 ]; then + printf '%s\n' "usage: $0 [-n] [-p] [-x EXT | -r NAME | -R] FILENAME" >&2 + printf '\t%s\n' "-n: dry run (don't actually upload anything)" >&2 + printf '\t%s\n' "-p: print uploaded url instead of copying to clipboard and notifying" >&2 + printf '\t%s\n' "-x EXT: set extension to EXT on uploaded filename" >&2 + printf '\t%s\n' "-r NAME: set remote name to NAME including extension" >&2 + printf '\t%s\n' "-R: set remote name to basename of FILENAME" >&2 + exit 1 +fi + +dry_run=0 +samename=0 +printurl=0 +override_rname= +while [ $# -gt 1 ]; do + if [ "$1" = "-x" ]; then + override_ext=".$2" + shift 2 + elif [ "$1" = "-n" ]; then + dry_run=1 + shift + elif [ "$1" = "-p" ]; then + printurl=1 + shift + elif [ "$1" = "-r" ]; then + override_rname="$2" + shift 2 + elif [ "$1" = "-R" ]; then + samename=1 + shift + else + printf "%s: unrecognized argument %s\n" "$0" "$1" >&2 + exit 2 + fi +done + +if [ ! -f "$1" ]; then + printf %s "$1: file does not exist" >&2 + exit 1 +fi + +if [ "$samename" -eq 1 ]; then + override_rname="$(basename "$1")" +fi + +REMOTE="do" +URLBASE="https://ubq323.website/files/" +REMOTEDIR="/srv/web/ubq/files/" + +ext="${1#*.}" +if [ "$ext" = "$1" ]; then + ext='.file' + bname="$(basename "$1")" +else + ext=".$ext" + bname="$(basename "$1" "$ext")" +fi +ext=${override_ext:-$ext} + +rbname="$(md5sum "$1"|cut -d' ' -f1|tr 'a-z' 'A-Z'|basenc -d --base16|basenc --base64url|head -c8)" +rname="${override_rname:-$rbname$ext}" + +exists_already() { + ssh "$REMOTE" stat "$REMOTEDIR$1" 2>/dev/null >/dev/null + return $? +} + +while exists_already "$rname"; do + printf "%s exists already\n" "$rname" >&2 + rname="_$rname" +done + +printf 'uploading to %s\n' "$rname" >&2 +if [ "$dry_run" -eq 1 ]; then + echo dryrun, not uploading anything + exit 0 +fi + +scp -q "$1" "${REMOTE}:$REMOTEDIR$rname" +ssh "$REMOTE" chmod a+r "$REMOTEDIR$rname" + +url="$URLBASE$rname" +if [ "$printurl" -eq 0 ]; then + printf %s "$url" | wl-copy + notify-send 'copied url to clipboard' "$url" +else + printf '%s\n' "$url" +fi + diff --git a/bin/rws b/bin/rws new file mode 100755 index 0000000..7041e8c --- /dev/null +++ b/bin/rws @@ -0,0 +1,99 @@ +#!/bin/sh + +# rebecca workspace +# +# source this from your shell rc file +# and also start rws -listen when you start sway + + +WSD=$XDG_RUNTIME_DIR/ws +mkdir -p $WSD + + + +wslist () { + # list workspaces, most-recently-used first + swaymsg -t get_workspaces | jq -rc '.[] | .name' | while read wsn; do + wsp=$WSD/"$(printf %s "$wsn" | base64)" + dt="$(stat -c '%Y' $wsp 2>/dev/null)" + if [ $? -eq 1 ]; then + dt=1 + fi + printf "%s\t%s\n" "$dt" "$wsn" + done | sort -nr | cut -f2- +} + +_escape() { + printf %s "$1" | sed -e 's*\\*\\\\*g' -e 's*"*\\"*g' +} + +workin () { + # cds to the given directory, then moves focused window to workspace + # with that name + if [ ! -d "$1" ]; then + printf "not a directory\n" >&2 + return 1 + else + cd "$1" + dirname="$(_escape "$(apwd)")" + swaymsg "move container to workspace \"$dirname\"" + swaymsg "workspace \"$dirname\"" + fi +} + + +curws () { + # prints name of current workspace + swaymsg -t get_workspaces \ + | jq -rc '.[] | select(.focused==true) | .name' +} +gowork() { + # cds to working directory for current workspace + d="$(curws|sed -e "s*^~*$HOME*")" + if [ -d "$d" ]; then + cd "$d" || return 1 + fi +} +renws () { + # renames current ws to current working dir + swaymsg "rename workspace to $(apwd)" +} + +queryws () { + # uses bmenu to prompt for a workspace name, then switches to that workspace + # or if -m given, moves focused window to that workspace instead + wsn="$(wslist | bemenu -p workspace -l100 --fn 'Iosevka Fixed 16' --tf '#df73ff' --hf '#df73ff' --hb '#333333')" + [ -z "$wsn" ] && return + + if [ "$1" = "-m" ]; then + swaymsg "move container to workspace \"$(_escape "$wsn")\"" + else + swaymsg "workspace \"$(_escape "$wsn")\"" + fi +} + + +_onswitch () { + wsb=$(printf %s "$1" | base64) + touch ${WSD}/$wsb +} +# run rws -listen to listen for workspace changes, +# and keep track of that +if [ "$1" = "-listen" ]; then + swaymsg -rmt subscribe '[ "workspace" ]' | while read line; do + wsn="$(printf %s "$line" | jq -rc '.current.name')" + printf "%s\n" "$wsn" + _onswitch "$wsn" + done +fi + +# rws -queryws does the same thing as queryws +# because it needs to be runnable from sway cfg in order to keybind something for it +if [ "$1" = "-queryws" ]; then + shift + queryws $@ +fi + + + + diff --git a/bin/status.sh b/bin/status.sh new file mode 100755 index 0000000..5bd9e4c --- /dev/null +++ b/bin/status.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +puts () { + printf %s "$1" +} + +escape () { + printf %s "$1" | sed -e 's*\\*\\\\*g' -e 's!"!\\"!g' +} + +block_basic () { + printf '{"full_text":"%s"},' "$1" +} +block_color () { + printf '{"full_text":"%s","color":"%s"},' "$1" "$2" +} + +BDIR=/sys/class/power_supply/BAT0 + +# header +printf '%s\n' '{"version":1}' +puts '[' + +while true; do + puts '[' + + volinfo="$(amixer get Master | grep 'Mono:')" + vol_level="$(printf %s "$volinfo" | awk -F'[][]' '{print $2}')" + vol_enabled="$(printf %s "$volinfo" | awk -F'[][]' '{print $6}')" + color="#ffffff"; bl=""; br="" + [ "$vol_enabled" = "off" ] && { color="#ffff00"; bl="("; br=")"; } + block_color "vol $bl$vol_level$br" "$color" + + bat_status="$(cat $BDIR/status | tr 'a-z' 'A-Z' | head -c 3)" + bat_level="$(cat $BDIR/capacity)" + color="#ffffff" + if [ "$bat_level" -le 10 ]; then + color="#ff0000" + elif [ "$bat_level" -le 25 ]; then + color="#ffff00" + fi + block_color "$bat_status $bat_level%" "$color" + + date="$(date +'%a %Y-%m-%d %H:%M:%S')" + block_basic "$date" + + + puts '],' + sleep 1 + +done + diff --git a/bin/ud b/bin/ud new file mode 100755 index 0000000..a1a50ac --- /dev/null +++ b/bin/ud @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +# unidump version 0.1.1 +# made by ubq323 in the year 2021 +# please use this software for GOOD, not for EVIL + +import unicodedata +import sys + +uniquify = True +arg="" +args = sys.argv[1:] +while len(args) > 0: + arg = args.pop(0) + if arg[0] != '-' or arg == "--": + break + if arg == "-a": + uniquify = False + arg = "" + + +s = arg+" ".join(args) + +if len(s) == 0: + s = sys.stdin.read() + +def row(c): + try: + name = unicodedata.name(c).rjust(50) + except ValueError: + name = "?"*50 + + number = ("U+"+hex(ord(c))[2:].zfill(4)).rjust(7).upper() + + to_c = c + if c == '\n': + to_c = ' ' + + + + return f"{to_c} | {unicodedata.category(c)} | {name} | {number}" + +seen = set() +for c in s: + if uniquify: + if c in seen: + continue + seen.add(c) + print(row(c)) -- cgit v1.2.3