From f32fc8b9eb8303d1ca2e1cc17773bc44d38fff3d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 27 May 2024 14:17:49 +0200 Subject: updated --- bin/extra/aivpn | 18 +++++------------- bin/menuscripts/mpass-otp | 2 +- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'bin') diff --git a/bin/extra/aivpn b/bin/extra/aivpn index 21436ed..841d926 100755 --- a/bin/extra/aivpn +++ b/bin/extra/aivpn @@ -16,23 +16,15 @@ done export SSH_ASKPASS="sshpass" export SSH_ASKPASS_REQUIRE="prefer" -export PASSWORD="zot/qemu" +export PASSWORD="zot/quickemu" err "I: Activating vpn" ssh vm "rasdial \"vpn.student.ehb.be\"" keyadd ehb/ai -ssh -f -N \ - -L 2222:10.2.160.41:22 \ - vm +ssh -f -N -L 2222:10.2.160.41:22 vm keyadd ehb/vm_int -ssh -f -N \ - -L 2223:10.2.160.9:22 \ - vm -ssh -f -N \ - -L 2224:10.2.160.10:22 \ - vm -ssh -f -N \ - -L 2225:10.2.160.11:22 \ - vm +ssh -f -N -L 2223:10.2.160.9:22 vm +ssh -f -N -L 2224:10.2.160.10:22 vm +ssh -f -N -L 2225:10.2.160.11:22 vm diff --git a/bin/menuscripts/mpass-otp b/bin/menuscripts/mpass-otp index 52d1341..2be6186 100755 --- a/bin/menuscripts/mpass-otp +++ b/bin/menuscripts/mpass-otp @@ -1,7 +1,7 @@ #!/bin/sh pass="$(find "$PASSWORD_STORE_DIR"/keys/otp -iname "*.gpg" | sed "/^\./d;s#^$PASSWORD_STORE_DIR/keys/otp/##;s/\.gpg$//" | - commander -c)" + dmenu -c)" [ "$pass" ] || exit 1 pass otp -c keys/otp/"$pass" notify-send -t 1000 "mpass" "copied $pass" -- cgit v1.2.3 From 2dab2233ef9cb54a3878e0120016d542045c7ee8 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 16 Jun 2024 16:16:11 +0200 Subject: checkpoint --- bin/extra/trl | 4 +- bin/guiscripts/mega.sh | 67 +++++++++++++++++++++ bin/guiscripts/osurf | 2 + bin/guiscripts/osurf-fill | 113 +++++++++++++++++++++++++++++++++++ bin/guiscripts/osurfls | 8 +++ bin/guiscripts/osurftabs | 12 ++++ bin/guiscripts/osurftxt | 22 +++++++ bin/guiscripts/record | 86 ++++++++++++++++++++++++++ bin/guiscripts/setbg | 5 ++ bin/guiscripts/yt | 4 ++ bin/menuscripts/tsh | 10 ++-- config/X/x11/xinitrc | 2 +- config/common/mpv/mpv.conf | 5 +- config/essentials/shell/aliases.sh | 1 + config/essentials/shell/functions.sh | 7 +++ config/essentials/zsh/.zshrc | 2 +- 16 files changed, 339 insertions(+), 11 deletions(-) create mode 100644 bin/guiscripts/mega.sh create mode 100755 bin/guiscripts/osurf create mode 100755 bin/guiscripts/osurf-fill create mode 100755 bin/guiscripts/osurfls create mode 100755 bin/guiscripts/osurftabs create mode 100755 bin/guiscripts/osurftxt create mode 100755 bin/guiscripts/record create mode 100755 bin/guiscripts/setbg create mode 100755 bin/guiscripts/yt (limited to 'bin') diff --git a/bin/extra/trl b/bin/extra/trl index bd4c2c5..55d65ee 100755 --- a/bin/extra/trl +++ b/bin/extra/trl @@ -41,10 +41,10 @@ then fi [ "$word" ] || exit 1 -primary="$(languages | fzf)" +primary="$(languages | fzf --prompt="from:")" [ "$primary" ] || exit 1 -secondary="$(languages | fzf)" +secondary="$(languages | fzf --prompt="to:")" [ "$secondary" ] || exit 1 curl -s "https://context.reverso.net/translation/$primary-$secondary/$word" \ diff --git a/bin/guiscripts/mega.sh b/bin/guiscripts/mega.sh new file mode 100644 index 0000000..cafca0a --- /dev/null +++ b/bin/guiscripts/mega.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +URL="" + +if [[ $1 =~ ^https?:\/\/mega(\.co)?\.nz ]]; then + URL="$1" +fi + +if [[ ! $URL ]]; then + echo "Usage: ${0##*/} url" >&2 + exit 1 +fi + +CURL="curl -Y 1 -y 10" + +missing=false +for cmd in openssl; do + if [[ ! $(command -v "$cmd" 2>&1) ]]; then + missing=true + echo "${0##*/}: $cmd: command not found" >&2 + fi +done +if $missing; then + exit 1 +fi + +if [[ $URL =~ .*/file/[^#]*#[^#]* ]]; then + id="${URL#*file/}"; id="${id%%#*}" + key="${URL##*file/}"; key="${key##*#}" +else + id="${URL#*!}"; id="${id%%!*}" + key="${URL##*!}" +fi + +raw_hex=$(echo "${key}=" | tr '\-_' '+/' | tr -d ',' | base64 -d -i 2>/dev/null | od -v -An -t x1 | tr -d '\n ') +hex=$(printf "%016x" \ + $(( 0x${raw_hex:0:16} ^ 0x${raw_hex:32:16} )) \ + $(( 0x${raw_hex:16:16} ^ 0x${raw_hex:48:16} )) +) + +json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "g":"1", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1; json="${json#"[{"}"; json="${json%"}]"}" +file_url="${json##*'"g":'}"; file_url="${file_url%%,*}"; file_url="${file_url//'"'/}" + +json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1 +at="${json##*'"at":'}"; at="${at%%,*}"; at="${at//'"'/}" + +json=$(echo "${at}==" | tr '\-_' '+/' | tr -d ',' | openssl enc -a -A -d -aes-128-cbc -K "$hex" -iv "00000000000000000000000000000000" -nopad | tr -d '\0'); json="${json#"MEGA{"}"; json="${json%"}"}" +file_name="${json##*'"n":'}" +if [[ $file_name == *,* ]]; then + file_name="${file_name%%,*}" +fi +file_name="${file_name//'"'/}" + +aria2c -x 15 -o "$file_name" "$file_url" +cat "$file_name" | openssl enc -d -aes-128-ctr -K "$hex" -iv "${raw_hex:32:16}0000000000000000" > "temp.new" +mv -f temp.new "$file_name" + +echo "$file_url" +echo "$file_name" +echo "$hex" +echo "${raw_hex:32:16}0000000000000000" +sleep 5 +echo "Downloading... (press Ctrl + C to Cancel)" + +aria2c -x 16 -s 16 -o "$file_name" "$file_url" +cat "$file_name" | openssl enc -d -aes-128-ctr -K "$hex" -iv "${raw_hex:32:16}0000000000000000" > "temp.new" +mv -f temp.new "$file_name" diff --git a/bin/guiscripts/osurf b/bin/guiscripts/osurf new file mode 100755 index 0000000..6923848 --- /dev/null +++ b/bin/guiscripts/osurf @@ -0,0 +1,2 @@ +#!/bin/sh +tabbed -c -dn tabbed-surf -r 2 surf -e '' "$1" diff --git a/bin/guiscripts/osurf-fill b/bin/guiscripts/osurf-fill new file mode 100755 index 0000000..311c273 --- /dev/null +++ b/bin/guiscripts/osurf-fill @@ -0,0 +1,113 @@ +#!/bin/sh +# bitwarden dmenu script - based off of the autofill userscript from qutebrowser +# requires the fifo patch +# $1: winid + +fifodir="$HOME/.config/surf/fifo" +if [ -z "${winid:=$1}" ] +then + winid="$(osurfls | dmenu -c -F -i | cut -f1 -d' ')" +fi +[ "$winid" ] || exit 1 +fifo="$fifodir/$winid" +[ -p "$fifo" ] || exit 2 + +url="$(xprop -id "$winid" _SURF_URI | + cut -f 2 -d'"' | + sed 's,^.*://\([^/]*\)/.*,\1,' | + sed -r -e 's/^([^.]+)\.([^.]+)\.([^.]+)$/\2.\3/')" +[ "$url" ] || exit 3 +>&2 printf 'url: %s\n' "$url" + + +pass="$({ find $PASSWORD_STORE_DIR/websites/ -type f -name '*.gpg' | + grep "$url/" || echo; } | head -n 1 | + sed "s,$PASSWORD_STORE_DIR/,,;s/\.gpg$//" | + dmenu -c)" +[ $? -gt 0 ] && exit 4 + +if [ -z "$pass" ] +then + store="${PASSWORD_STORE_DIR:-$HOME/.password-store}" + while [ -d "$store/$file" ] + do + choice="$(find "$store/$file" \ + -maxdepth 1 -mindepth 1 \ + -not -name '.*' -type d -printf "%y\t%f\n" -o \ + -not -name '.*' -not -type d -printf "%y\t%f\n" | + sort -k1 -k2 | + cut -f 2 | sed 's/\.gpg$//' | + dmenu -c)" + [ "$choice" ] || exit 1 + [ -z "$file" ] && file="$choice" || file="$file/$choice" + done + pass="$file" +fi +>&2 printf 'pass: %s\n' "$pass" + +herbe "filling ${pass#websites/}" & + +# Get password and username in variables with only one call to 'pass' +eval "$(pass show "$pass" | + sed -n "1s/'/'\\\\''/g;1s/.*/password='&'/p;s/^login: \?\(.\+\)/username='\1'/p")" +printf '%s : %s\n' "$username" "$password" + +javascript_escape() { + printf '%s' "$1" | sed -s 's,['\''"\\\\],\\\\&,g' +} + +js() { +cat < 0 && elem.offsetHeight > 0; + }; + function hasPasswordField(form) { + var inputs = form.getElementsByTagName("input"); + for (var j = 0; j < inputs.length; j++) { + var input = inputs[j]; + if (input.type == "password" || input.autocomplete == "password" || input.name == "password") { + return true; + } + } + return false; + }; + function loadData2Form (form) { + var inputs = form.getElementsByTagName("input"); + for (var j = 0; j < inputs.length; j++) { + var input = inputs[j]; + if (isVisible(input) && (input.type == "text" || input.type == "email")) { + input.focus(); + input.value = "$(javascript_escape "$username")"; + input.blur(); + console.log("user: $(javascript_escape "$username")") + } + if (input.type == "password" || input.name == "password" || input.autocomplete == "password" || input.id == "password" ) { + input.focus(); + input.value = "$(javascript_escape "$password")"; + input.blur(); + console.log("password: $(javascript_escape "$password")") + } + console.log(input) + } + }; + var forms = document.getElementsByTagName("form"); + for (i = 0; i < forms.length; i++) { + if (hasPasswordField(forms[i])) { + loadData2Form(forms[i]); + // forms[i].submit(); + } + } +EOF +} + +printjs() { + js | sed 's,//.*$,,' | tr '\n' ' ' +} + +echo "inject $(printjs)" >> "$fifo" diff --git a/bin/guiscripts/osurfls b/bin/guiscripts/osurfls new file mode 100755 index 0000000..0abdd35 --- /dev/null +++ b/bin/guiscripts/osurfls @@ -0,0 +1,8 @@ +#!/bin/sh +find "$HOME/.config/surf/fifo" -type p -printf '%f\n' | +while read -r winid +do + title="$(xprop -id "$winid" 2> /dev/null | awk -F'"' '/^_NET_WM_NAME/ {print $2}')" + [ "$title" ] || continue + printf '%s %s\n' "$winid" "$title" +done \ No newline at end of file diff --git a/bin/guiscripts/osurftabs b/bin/guiscripts/osurftabs new file mode 100755 index 0000000..d41424b --- /dev/null +++ b/bin/guiscripts/osurftabs @@ -0,0 +1,12 @@ +#!/bin/sh + +# list surf tabbed windows + +# dependencies: lsw, dmenu, xprop +# expects the tabbed windows to be named 'tabbed-surf' +lsw | cut -f1 -d' ' | + while read -r winid + do + [ "tabbed-surf" = "$(xprop -id "$winid" WM_CLASS | cut -f2 -d'"')" ] && + printf '%s %s\n' "$winid" "$(xprop -id "$winid" WM_NAME | cut -f2 -d'"')" + done diff --git a/bin/guiscripts/osurftxt b/bin/guiscripts/osurftxt new file mode 100755 index 0000000..ef60166 --- /dev/null +++ b/bin/guiscripts/osurftxt @@ -0,0 +1,22 @@ +#!/bin/sh + +# open all links in txt file into one tabbed surf + +# dependencies: surf, osurf, dmenu + +# $1: file path for non interactive use +if [ -z "$1" ] +then + d="$HOME/dl/txtabs" + f="$(find "$d" -type f -printf '%f\n' | dmenu)" + [ "$f" ] || exit 1 + f="$d"/"$f" +else + [ -f "$1" ] || exit 1 + f="$1" +fi + +winid="$(osurf "$(head -n 1 "$f")")" +tail -n +2 "$f" | while read -r url; + do surf -e "$winid" "$url" & + done diff --git a/bin/guiscripts/record b/bin/guiscripts/record new file mode 100755 index 0000000..778e02e --- /dev/null +++ b/bin/guiscripts/record @@ -0,0 +1,86 @@ +#!/bin/sh + +# record - record an area of the screen + +lock="/tmp/record.lock" + +# dependencies: ffmpeg, hacksaw (part), xwininfo & lsw (window), xdotool (active) +# optional: +# - hacksaw: part +# - xwininfo, lsw, commander: window +# - xdotool: active +# - xdg-user-dir + +# $1: width +# $2: height +# $3: x +# $4: y +# $5: output dir +# $6: output name +record_cmd() +{ + if [ -f "$lock" ] + then + >&2 printf 'already recording, please stop recording first\n' + exit 1 + else + touch "$lock" + fi + + herbe "started recording." & + w=$(($3 + $3 % 2)) + h=$(($4 + $4 % 2)) + ffmpeg \ + -v 16 \ + -r 30 \ + -f pulse -ac 2 -i default \ + -f x11grab \ + -s "${w}x${h}" \ + -i ":0.0+$1,$2" \ + -preset slow \ + -c:v h264 \ + -pix_fmt yuv420p \ + -crf 20 \ + "$5/$6.mp4" + printf '%s\n' "$5/$6.mp4" + rm -f "$lock" + herbe "stopped recording." & +} + +if [ -d "$1" ] +then + dir="$1" + shift +else + dir="$(which xdg-user-dir > /dev/null 2>&1 && xdg-user-dir VIDEOS)" + [ "$dir" ] && dir="$dir/records" || dir="$HOME/vids/records" +fi +mkdir -p "$dir" + +current=$(date +%F_%H-%M-%S) + +[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\n' | commander -c)" +case "$option" in + active) + record_cmd $(xwininfo -id "$(xdotool getactivewindow)" | + sed -e '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ') $dir $current + ;; + + window) + winid="$(lsw | commander -cxl | cut -d' ' -f1)" + [ "$winid" ] || exit 1 + values="$(xwininfo -id "$winid" | sed -e '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ')" + [ "$values" ] || exit 1 + record_cmd $values $dir $current + ;; + + part) + hacksaw | { + IFS=+x read -r w h x y + record_cmd $w $h $x $y $dir $current + } + ;; + stop) kill "$(pgrep ffmpeg | xargs ps | grep 'x11grab' | awk '{print $1}')"; rm -f "$lock" ;; + full) record_cmd 0 0 1920 1080 $dir $current ;; + help|*) >&2 printf 'record [dir] (active|window|part|stop|full)\n' ;; +esac diff --git a/bin/guiscripts/setbg b/bin/guiscripts/setbg new file mode 100755 index 0000000..a4109ab --- /dev/null +++ b/bin/guiscripts/setbg @@ -0,0 +1,5 @@ +#!/bin/sh +cd "$HOME/pics/wallpapers" || exit 1 +bg="$(find . -type f -printf '%f\n' | sed 's@^\./@@' | dmenu -c -x)" +[ "$bg" ] || exit 1 +feh --no-fehbg --bg-scale "$bg" diff --git a/bin/guiscripts/yt b/bin/guiscripts/yt new file mode 100755 index 0000000..72f6e92 --- /dev/null +++ b/bin/guiscripts/yt @@ -0,0 +1,4 @@ +#!/bin/sh +link="$(ytfzf -D -I l)" +[ "$link" ] || exit 1 +yt-dlp $@ -o - "$link" | mpv - diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index aac27ee..70e7ca8 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -5,8 +5,8 @@ PROG="$(basename "$0")" # copy command and deps variable deps="pup curl $MENUCMD" -LIBPFX=/home/aluc/.local/share/tsh -module='1337x.sh' # default module +MODULES_PATH=$HOME/.local/share/tsh +module='nyaa.sh' # default module # Files export tmp="/tmp/$PROG" @@ -83,7 +83,7 @@ cleanup () done } -list_modules () { find -L "$LIBPFX" -type f -printf "%f\n"; } +list_modules () { find -L "$MODULES_PATH" -type f -printf "%f\n"; } # get a query from user based on MENUCMD get_query () @@ -179,7 +179,7 @@ then # Get results rm -f "$results" "$links" # shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 - . "$LIBPFX/$module" + . "$MODULES_PATH/$module" [ -f "$results" ] || die "No results." # Save which module was used @@ -190,7 +190,7 @@ fi # acquire get_magnet function # shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 -getfunctions=1 . "$LIBPFX/$module" +getfunctions=1 . "$MODULES_PATH/$module" # select result from "$results" for choice in $(select_result | xargs) diff --git a/config/X/x11/xinitrc b/config/X/x11/xinitrc index bc1824a..8b3cf2b 100755 --- a/config/X/x11/xinitrc +++ b/config/X/x11/xinitrc @@ -22,7 +22,7 @@ export MENUCMD="dmenu" export IMAGE="feh" xcompmgr & feh --no-fehbg --bg-scale ~/pics/wallpaper -setxkbmap us -option ctrl:swapcaps,altwin:menu_win -variant colemak +setxkbmap colemak -option ctrl:swapcaps,altwin:menu_win # xautolock -locker slock & gammastep -m randr & # dunst & diff --git a/config/common/mpv/mpv.conf b/config/common/mpv/mpv.conf index 1fd96da..2e7318e 100755 --- a/config/common/mpv/mpv.conf +++ b/config/common/mpv/mpv.conf @@ -17,10 +17,11 @@ ytdl-raw-options=extractor-args="youtube:player-client=android" # Default demuxer is 150/75 MB, note that this uses RAM so set a reasonable amount. # 150MB, Max pre-load for network streams (1 MiB = 1048576 Bytes). -demuxer-max-bytes=150000000 +demuxer-max-bytes=150MiB +demuxer-readahead-secs=20 # 75MB, Max loaded video kept after playback. -demuxer-max-back-bytes=75000000 +demuxer-max-back-bytes=75MiB # Force stream to be seekable even if disabled. force-seekable=yes diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index a8b9036..be35a6c 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -339,6 +339,7 @@ alias ddeps='pactree -r -d 1' alias update-mirrors='reflector -p https | rankmirrors -n 10 -p -w - | doas tee /etc/pacman.d/mirrorlist' alias tmpd='cd $(mktemp -d)' +alias tmpf='$EDITOR $(mktemp)' alias brs='$BROWSER' which bat > /dev/null 2>&1 && alias cat="bat -p" diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index b69b775..945b716 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -241,6 +241,7 @@ pacsize() mime-default () { + mime= [ "${mime:=$1}" ] || mime="$(find /usr/share/applications/ -iname '*.desktop' -printf '%f\n' | sed 's/\.desktop$//' | @@ -364,3 +365,9 @@ ssh_port() ssh -f -N -L 0.0.0.0:"$3":localhost:"$1" "$2" >&2 printf "Forwarded port '%s' on '%s' to '%s'.\n" "$1" "$2" "$3" } +ffconcat () { + tmp=$(mktemp -p . ffconcat.XXXXX) + sed 's/.*/file &/' > "$tmp" + ffmpeg -y -f concat -safe 0 -i $tmp -c copy "$1" + rm $tmp +} diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 545f9cc..6bd948a 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -58,7 +58,7 @@ fi # Add nnn shell level to prompt -[ -n "$NNNLVL" ] && PS1="N$NNNLVL $PS1" +[ -n "$NNNLVL" ] && PS1="N$NNNLVL$PS1" # cd on nnn quiting nnn_cd () -- cgit v1.2.3 From 84dc4d81c70af431c786b5080307d6bb87a0162e Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 17 Jun 2024 00:29:32 +0200 Subject: checkpoint --- bin/guiscripts/startw | 4 ---- bin/menuscripts/tsh | 11 ++--------- config/common/mpd/mpd.conf | 2 +- config/common/mpv/scripts/mpv-skipsilence | 1 + config/home/.zshenv | 4 ++-- config/wayland/hypr/hyprland.conf | 2 +- 6 files changed, 7 insertions(+), 17 deletions(-) create mode 160000 config/common/mpv/scripts/mpv-skipsilence (limited to 'bin') diff --git a/bin/guiscripts/startw b/bin/guiscripts/startw index 0383f48..dbf4450 100755 --- a/bin/guiscripts/startw +++ b/bin/guiscripts/startw @@ -1,8 +1,4 @@ #!/bin/sh - eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg,ssh)" eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" - -(cd ~/.config/waybar/ && ln -sf hyprland.jsonc config.jsonc) - Hyprland diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index 70e7ca8..0c57ee0 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -121,14 +121,6 @@ show_files() rm -f "$tmp"/.torrent } -# Select a type after having displayed them with 'show_types' -select_type() -{ - for type in $categories - do printf "%s\n" "$type" - done | fzf -} - trap "exit 1" INT trap "cleanup" EXIT @@ -205,7 +197,8 @@ do if [ "$noaskdownload" ] || confirm 'download?' then - [ "${category:-$(select_type)}" ] || exit 1 + [ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)" + [ "$category" ] || exit 2 transmission-remote debuc.com -a "$magnet" -w "/downloads/$category" elif confirm "copy?" then diff --git a/config/common/mpd/mpd.conf b/config/common/mpd/mpd.conf index 095b345..889b458 100644 --- a/config/common/mpd/mpd.conf +++ b/config/common/mpd/mpd.conf @@ -1,4 +1,4 @@ -music_directory "/media/manthe/music" +music_directory "~/music" playlist_directory "~/.config/mpd/playlists" db_file "~/.config/mpd/database" pid_file "~/.config/mpd/pid" diff --git a/config/common/mpv/scripts/mpv-skipsilence b/config/common/mpv/scripts/mpv-skipsilence new file mode 160000 index 0000000..2d6fd04 --- /dev/null +++ b/config/common/mpv/scripts/mpv-skipsilence @@ -0,0 +1 @@ +Subproject commit 2d6fd04dca3c70edf816e9af6fc30b302eb1c7ac diff --git a/config/home/.zshenv b/config/home/.zshenv index 1d732ab..a87f01d 100644 --- a/config/home/.zshenv +++ b/config/home/.zshenv @@ -81,8 +81,8 @@ export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS' export LESS="-i -r" # Colored manpages -export MANPAGER="less -R --use-color -Dd+r -Du+b" -export MANROFFOPT="-P -c" +# export MANPAGER="less -R --use-color -Dd+r -Du+b" +# export MANROFFOPT="-P -c" export CM_LAUNCHER="commander -c" diff --git a/config/wayland/hypr/hyprland.conf b/config/wayland/hypr/hyprland.conf index 0a00b31..d084eb9 100644 --- a/config/wayland/hypr/hyprland.conf +++ b/config/wayland/hypr/hyprland.conf @@ -31,7 +31,7 @@ general { layout = dwindle - cursor_inactive_timeout = 0 + # cursor_inactive_timeout = 0 } misc { -- cgit v1.2.3 From b0cf79d522a609eda250629386eb45c2978ef2d8 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jun 2024 15:34:10 +0200 Subject: checkpoint --- bin/guiscripts/record | 20 +++++++++++++++++--- bin/menuscripts/keyadd | 2 +- config/common/tmux/tmux.conf | 2 +- config/essentials/zsh/.zshrc | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/guiscripts/record b/bin/guiscripts/record index 778e02e..df4b6e6 100755 --- a/bin/guiscripts/record +++ b/bin/guiscripts/record @@ -11,6 +11,8 @@ lock="/tmp/record.lock" # - xdotool: active # - xdg-user-dir +audio= + # $1: width # $2: height # $3: x @@ -30,10 +32,9 @@ record_cmd() herbe "started recording." & w=$(($3 + $3 % 2)) h=$(($4 + $4 % 2)) - ffmpeg \ + ffmpeg $audio \ -v 16 \ -r 30 \ - -f pulse -ac 2 -i default \ -f x11grab \ -s "${w}x${h}" \ -i ":0.0+$1,$2" \ @@ -57,9 +58,21 @@ else fi mkdir -p "$dir" +if [ "$1" = "-a" ] +then + audio="-f pulse -ac 2 -i default" + shift +fi + +if [ "$1" = "-l" ] +then + find vids/records/ -type f | sort | tail -n 1 + exit +fi + current=$(date +%F_%H-%M-%S) -[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\n' | commander -c)" +[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\naudio' | commander -c)" case "$option" in active) record_cmd $(xwininfo -id "$(xdotool getactivewindow)" | @@ -82,5 +95,6 @@ case "$option" in ;; stop) kill "$(pgrep ffmpeg | xargs ps | grep 'x11grab' | awk '{print $1}')"; rm -f "$lock" ;; full) record_cmd 0 0 1920 1080 $dir $current ;; + audio) $0 -a; exit ;; help|*) >&2 printf 'record [dir] (active|window|part|stop|full)\n' ;; esac diff --git a/bin/menuscripts/keyadd b/bin/menuscripts/keyadd index 12519ec..4e7949f 100755 --- a/bin/menuscripts/keyadd +++ b/bin/menuscripts/keyadd @@ -2,7 +2,7 @@ log() { - notify-send -t 1000 "keyadd" "$1" + notify-send -t 1000 "keyadd" "$1" & >&2 printf '%s\n' "$1" } diff --git a/config/common/tmux/tmux.conf b/config/common/tmux/tmux.conf index 9300c97..8cf10e5 100755 --- a/config/common/tmux/tmux.conf +++ b/config/common/tmux/tmux.conf @@ -120,7 +120,7 @@ set -g status on #+--- Layout ---+ set -g set-titles-string "[#S: #W] #T" set -g set-titles on -set -g status-position top +set -g status-position bottom set -g window-status-current-style "underscore" set -g status-justify left set -g status-left-length 16 diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 6bd948a..8aa9f5e 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -41,7 +41,7 @@ plug "zsh-users/zsh-completions" plug "MichaelAquilina/zsh-auto-notify" export AUTO_NOTIFY_TITLE="zsh" export AUTO_NOTIFY_BODY="%command [%exit_code]" -AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis") +AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis" "clock") # Substring search settings export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="bg=blue,fg=black,bold" -- cgit v1.2.3 From 05e1216b45340702f82a4946002015a05cebe9b1 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jun 2024 16:12:01 +0200 Subject: checkpoint --- bin/extra/clock | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/extra/ddsurf | 4 ++++ bin/extra/igdl | 21 +++++++++++++++++ bin/extra/mtr | 23 +++++++++++++++++++ bin/extra/muz-sync | 10 ++++++++ bin/extra/myalscore.sh | 7 ++++++ bin/extra/spschedule | 2 ++ bin/extra/trmv | 13 +++++++++++ 8 files changed, 142 insertions(+) create mode 100755 bin/extra/clock create mode 100755 bin/extra/ddsurf create mode 100755 bin/extra/igdl create mode 100755 bin/extra/mtr create mode 100755 bin/extra/muz-sync create mode 100755 bin/extra/myalscore.sh create mode 100755 bin/extra/spschedule create mode 100755 bin/extra/trmv (limited to 'bin') diff --git a/bin/extra/clock b/bin/extra/clock new file mode 100755 index 0000000..fdffae0 --- /dev/null +++ b/bin/extra/clock @@ -0,0 +1,62 @@ +#!/bin/sh + +clocks="${XDG_DATA_HOME:-$HOME}"/clocks.csv + +if [ ! -f "$clocks" ] +then + printf 'start,end,message\n' > "$clocks" +fi + +if [ "$1" = "-c" ] +then + # empty + [ "$(wc -l < "$clocks")" -eq 1 ] && exit + + timefmt="%y%m%d-%T" + IFS="," + # skip csv header + tail -n +2 "$clocks" | + while read -r start end message + do + printf "%s - %s | %s\n" "$(date -d "@$start" +"$timefmt" )" "$(date -d "@$end" +"$timefmt")" "$message" + done + exit +fi + +if [ "$1" = "-e" ] +then + $EDITOR "$clocks" + exit +fi + +trap 'exit 0' INT # The proper way to exit + +while true +do + >&2 printf ' > ' + message="$(head -n 1)" + + [ "$message" ] || exit 1 + printf '\033[1A' # move cursor up once: https://en.wikipedia.org/wiki/ANSI_escape_code + + start_time="$(date +%s)" + start_time_pretty="$(date -d "@$start_time" +%R)" + >&2 printf -- '\r%s- > %s' "$start_time_pretty" "$message" + + # Wait for EOF + cat > /dev/null 2>&1 + + end_time="$(date +%s)" + end_time_pretty="$(date -d "@$end_time" +%R)" + >&2 printf -- '\r%s-%s > %s\n' "$start_time_pretty" "$end_time_pretty" "$message" + + if printf '%s' "$message" | grep ',' > /dev/null + then + # escape potential double quotes + message="$(printf '%s' "$message" | sed -e 's/"/""/g')" + message="\"$message\"" + fi + + # save clocked time and message + printf '%s,%s,%s\n' "$start_time" "$end_time" "$message" >> "$clocks" +done diff --git a/bin/extra/ddsurf b/bin/extra/ddsurf new file mode 100755 index 0000000..a3ae0d1 --- /dev/null +++ b/bin/extra/ddsurf @@ -0,0 +1,4 @@ +#!/bin/sh +f="$(mktemp)" +awk '!x[$2]++' ~/.config/surf/history.txt > "$f" +mv "$f" ~/.config/surf/history.txt diff --git a/bin/extra/igdl b/bin/extra/igdl new file mode 100755 index 0000000..1973187 --- /dev/null +++ b/bin/extra/igdl @@ -0,0 +1,21 @@ +#!/bin/sh +lock="/tmp/igdl.lock" + +if [ -f "$lock" ] +then + herbe "already downloading." + exit 1 +fi + + +url="$(clipo)" +out="/tmp/igdl.mp4" + +touch "$lock" +herbe "igdl" "downloading: $url" & +yt-dlp "$url" -o "$out" || rm "$lock" + +printf '%s' "$out" | clipp +herbe "igdl" "copied path." + +rm "$lock" diff --git a/bin/extra/mtr b/bin/extra/mtr new file mode 100755 index 0000000..486a9b8 --- /dev/null +++ b/bin/extra/mtr @@ -0,0 +1,23 @@ +#!/bin/sh + +list_categories() +{ + cat <$category" diff --git a/bin/extra/muz-sync b/bin/extra/muz-sync new file mode 100755 index 0000000..a81ef74 --- /dev/null +++ b/bin/extra/muz-sync @@ -0,0 +1,10 @@ +#!/bin/sh +trap "exit 1" INT + +music="$(xdg-user-dir MUSIC)" +>&2 printf "music: %s\n" "$music" + +# recursive, links, fuzzy, partial, progress +while ! rsync -rlyP --size-only db:/media/basilisk/music/sorted/ "$music" +do : +done diff --git a/bin/extra/myalscore.sh b/bin/extra/myalscore.sh new file mode 100755 index 0000000..ef68bcc --- /dev/null +++ b/bin/extra/myalscore.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +[ "$1" ] || exit 1 +query="$(printf '%s' "$*" | sed 's/\s/%20/g')" +curl -s "https://myanimelist.net/search/prefix.json?type=all&keyword=$query&v=1" \ + -H 'Accept: application/json, text/javascript, */*; q=0.01' | + jq -r '.categories[].items[] | [.payload.score, .name] | join(" ")' diff --git a/bin/extra/spschedule b/bin/extra/spschedule new file mode 100755 index 0000000..b0dd70a --- /dev/null +++ b/bin/extra/spschedule @@ -0,0 +1,2 @@ +#!/bin/sh +curl -s 'https://subsplease.org/api/?f=schedule&tz=UTC' | jq -r ".schedule.$(date +%A).[] | [.time, .title] | join(\" \")" diff --git a/bin/extra/trmv b/bin/extra/trmv new file mode 100755 index 0000000..22d9e48 --- /dev/null +++ b/bin/extra/trmv @@ -0,0 +1,13 @@ +#!/bin/sh + +trr() { transmission-remote 192.168.178.79 "$@"; } + +id="$(trr -t all -l | tail -n +2 | head -n -1 | fzf | awk '{print $1}')" +[ "$id" ] || exit 1 +name="$(trr -t "$id" -i | grep '^\s*Name:' | cut -f 4- -d ' ')" +location="$(trr -t "$id" -i | grep '^\s*Location:' | cut -f 4- -d ' ')" + +>&2 printf '#%s\n' "$id" +>&2 printf "old name: %s\n" "$name" +>&2 printf 'new name: ' +trr -t "$id" --path "$name" --rename "$(head -n 1)" -- cgit v1.2.3 From 4bf952169c5d94044a6dd3c868c990716d22c58b Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 19 Jun 2024 10:28:46 +0200 Subject: checkpoint --- bin/extra/ytplay | 4 +++- config/essentials/shell/aliases.sh | 3 ++- config/essentials/zsh/.zshrc | 12 ++++++------ config/extra/mutt/.gitignore | 1 + config/extra/mutt/muttrc | 1 + 5 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 config/extra/mutt/.gitignore create mode 100644 config/extra/mutt/muttrc (limited to 'bin') diff --git a/bin/extra/ytplay b/bin/extra/ytplay index b5c1a8c..5243364 100755 --- a/bin/extra/ytplay +++ b/bin/extra/ytplay @@ -1,2 +1,4 @@ #!/bin/sh -yt-dlp -o - "$(ytlink)" | mpv - +url="$(ytlink)" +herbe "playing: $url" & +yt-dlp -o - "$url" | mpv - diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index 44aa7bc..5db3d65 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -3,7 +3,8 @@ # The most important one alias vi='nvim' -alias cd='z' +which z > /dev/null 2>&1 && + alias cd='z' # Zsh specific aliases if [ $SHELL = "/bin/zsh" ] diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 6e28602..2b3ae1a 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -7,8 +7,6 @@ then [ "${TTY%%tty*}" = '/dev/' ] && clear case "${TTY#/dev/tty}" in 1) exec startx > /dev/null 2>&1 ;; - 2) exec startdwl > /dev/null 2>&1 ;; - 3) exec startw > /dev/null 2>&1 ;; *) false ;; esac && exit fi @@ -18,10 +16,12 @@ autoload -z edit-command-line zle -N edit-command-line ### Source files -. $XDG_CONFIG_HOME/zsh/comp.zsh -. $XDG_CONFIG_HOME/shell/functions.sh -. $XDG_CONFIG_HOME/shell/aliases.sh -. $XDG_CONFIG_HOME/zsh/widgets.zsh +source_it() { [ -f "$1" ] && . "$1" } +source_it /etc/profile.d/plan9.sh +source_it $XDG_CONFIG_HOME/zsh/comp.zsh +source_it $XDG_CONFIG_HOME/shell/functions.sh +source_it $XDG_CONFIG_HOME/shell/aliases.sh +source_it $XDG_CONFIG_HOME/zsh/widgets.zsh # . $XDG_CONFIG_HOME/zsh/prompt.zsh # . $XDG_CONFIG_HOME/zsh/plugins.zsh diff --git a/config/extra/mutt/.gitignore b/config/extra/mutt/.gitignore new file mode 100644 index 0000000..5e46596 --- /dev/null +++ b/config/extra/mutt/.gitignore @@ -0,0 +1 @@ +cache \ No newline at end of file diff --git a/config/extra/mutt/muttrc b/config/extra/mutt/muttrc new file mode 100644 index 0000000..a5cfa90 --- /dev/null +++ b/config/extra/mutt/muttrc @@ -0,0 +1 @@ +source /home/aluc/.config/mutt/configs/raymaekers.luca@gmail.com -- cgit v1.2.3 From 947f7df73f16981f170265a64a964142fc617023 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 20 Jun 2024 12:01:39 +0200 Subject: checkpoint --- bin/common/gt | 111 +++++++++++++++++++++ bin/guiscripts/osurf-fill | 22 +++- bin/guiscripts/osurftxt | 28 +++--- bin/guiscripts/osurftxts | 22 ++++ config/essentials/shell/aliases.sh | 3 - config/essentials/shell/functions.sh | 2 +- .../essentials/vis/plugins/vis-snippets/init.lua | 0 config/essentials/vis/visrc.lua | 1 + 8 files changed, 165 insertions(+), 24 deletions(-) create mode 100755 bin/common/gt create mode 100755 bin/guiscripts/osurftxts create mode 100644 config/essentials/vis/plugins/vis-snippets/init.lua (limited to 'bin') diff --git a/bin/common/gt b/bin/common/gt new file mode 100755 index 0000000..bdbd00f --- /dev/null +++ b/bin/common/gt @@ -0,0 +1,111 @@ +#!/bin/sh + +# Git Trach, track the state of multiple repos from a single file. + +# dependencies: +# - git +# - $EDITOR: -e +# - herbe (optional): -s + +repos="${XDG_DATA_HOME:-$HOME}"/git-track.txt +touch "$repos" + +help() { + >&2 cat </dev/null | while read -r line + # \r\033[0K : clear current line + do >&2 printf '\r\033[0K%s' "$line" + done +} + +# Print repositories prettily +# This function function prints animations (eg. clearing the line) +# to stderr and the final status line is outputted to stdout. +status() { + while read -r repo + do + repo_pretty="$(printf '%s' "$repo" | sed "s@$HOME@~@" )" + + # absolute path + cd "$repo" + + # replace line with status + >&2 printf '\r\033[0K' + + status="$(git status --porcelain 2> /dev/null | awk '{print $1}' | uniq | tr -d '\n')" + remote="$(git branch -v 2>/dev/null | sed 's/ahead/↑/;s/behind/↓/;s/[^↓↑]*//g')" + + printf '%s %s %s\n' "$repo_pretty" "$status" "$remote" + done < "$repos" +} + +# run git command in each repo +# $1: command +repos_cmd() { + while read -r repo + do + repo_pretty="$(printf '%s' "$repo" | sed "s@$HOME@~@" )" + printf ''\''%s'\'' in %s' "$1" "$repo_pretty" + ( + cd "$repo" + git "$1" > /dev/null 2>&1 + [ $? -gt 0 ] && s="x" || s="o" + printf '\r\033[0K%s: %s\n' "$repo_pretty" "$s" + ) + done < "$repos" +} + +# no options +if [ -z "$1" ] +then + help + exit 1 +fi + +while getopts ":a:c:f:lshe" opt +do + case "$opt" in + a) + cd "$OPTARG" || exit 1 + r="$(git rev-parse --show-toplevel)" + [ "$r" ] || exit 2 + + if grep "$r" "$repos" > /dev/null 2>&1 + then + >&2 printf 'added already.\n' + exit 2 + fi + + printf '%s\n' "$r" >> "$repos" + + >&2 printf 'added.\n' ;; + c) repos_cmd "$OPTARG" ;; + s) status=1 ;; + l) cat "$repos" ;; + e) $EDITOR "$repos" ;; + f) repos="$OPTARG" ;; + T) help ;; + :) >&2 printf -- '-%s requires argument\n' "$OPTARG"; exit 1 ;; + ?) >&2 printf -- 'Invalid option: -%s\n' "$OPTARG"; exit 1 ;; + esac +done + +if [ "$status" ] +then + status + which herbe > /dev/null 2>&1 && + eval "herbe $(status | sed 's/"/\"/g;s/.*/"&"/' | tr '\n' ' ')" & +fi diff --git a/bin/guiscripts/osurf-fill b/bin/guiscripts/osurf-fill index 311c273..43af807 100755 --- a/bin/guiscripts/osurf-fill +++ b/bin/guiscripts/osurf-fill @@ -1,6 +1,16 @@ #!/bin/sh -# bitwarden dmenu script - based off of the autofill userscript from qutebrowser -# requires the fifo patch + +# Fills a password for a given website +# original script by Avalon Williams (avalonwilliams@protonmail.com) +# This version uses the window id to know the url of the surf window +# and to know which fifo it must use. Then it injects javascript code. +# that will fill the forms with the credentials + +# dependencies: +# - surf fifo patch (http://surf.suckless.org/patches/fifo/) +# - xprop +# - 'pass' with password store in form dir/url/pass.gpg + # $1: winid fifodir="$HOME/.config/surf/fifo" @@ -12,6 +22,7 @@ fi fifo="$fifodir/$winid" [ -p "$fifo" ] || exit 2 +# Get only domain name + top-level domain url="$(xprop -id "$winid" _SURF_URI | cut -f 2 -d'"' | sed 's,^.*://\([^/]*\)/.*,\1,' | @@ -19,13 +30,15 @@ url="$(xprop -id "$winid" _SURF_URI | [ "$url" ] || exit 3 >&2 printf 'url: %s\n' "$url" - +# get pass with url and ask if multiple are found pass="$({ find $PASSWORD_STORE_DIR/websites/ -type f -name '*.gpg' | grep "$url/" || echo; } | head -n 1 | sed "s,$PASSWORD_STORE_DIR/,,;s/\.gpg$//" | dmenu -c)" +# if dmenu was stopped, exit [ $? -gt 0 ] && exit 4 +# if no password was found, search through password store manually with dmenu if [ -z "$pass" ] then store="${PASSWORD_STORE_DIR:-$HOME/.password-store}" @@ -44,14 +57,15 @@ then pass="$file" fi >&2 printf 'pass: %s\n' "$pass" - herbe "filling ${pass#websites/}" & # Get password and username in variables with only one call to 'pass' +# escape single quotes eval "$(pass show "$pass" | sed -n "1s/'/'\\\\''/g;1s/.*/password='&'/p;s/^login: \?\(.\+\)/username='\1'/p")" printf '%s : %s\n' "$username" "$password" +# Escape quotes and backslashes for javascript javascript_escape() { printf '%s' "$1" | sed -s 's,['\''"\\\\],\\\\&,g' } diff --git a/bin/guiscripts/osurftxt b/bin/guiscripts/osurftxt index ef60166..9a1d4f4 100755 --- a/bin/guiscripts/osurftxt +++ b/bin/guiscripts/osurftxt @@ -1,22 +1,18 @@ #!/bin/sh -# open all links in txt file into one tabbed surf +# open a link from a txt file in surf # dependencies: surf, osurf, dmenu -# $1: file path for non interactive use -if [ -z "$1" ] -then - d="$HOME/dl/txtabs" - f="$(find "$d" -type f -printf '%f\n' | dmenu)" - [ "$f" ] || exit 1 - f="$d"/"$f" -else - [ -f "$1" ] || exit 1 - f="$1" -fi +winid="$1" +>&2 printf 'winid: %s\n' "$winid" +tabs="$HOME/dl/txtabs" -winid="$(osurf "$(head -n 1 "$f")")" -tail -n +2 "$f" | while read -r url; - do surf -e "$winid" "$url" & - done +f="$(find "$tabs" -type f -printf '%f\n' | dmenu -c)" +[ "$f" ] || exit 1 +f="$tabs"/"$f" +>&2 printf 'f: %s\n' "$f" + +url="$(dmenu -c < "$f")" + +printf 'loaduri %s' "$url" > $HOME/.config/surf/fifo/$winid diff --git a/bin/guiscripts/osurftxts b/bin/guiscripts/osurftxts new file mode 100755 index 0000000..ef60166 --- /dev/null +++ b/bin/guiscripts/osurftxts @@ -0,0 +1,22 @@ +#!/bin/sh + +# open all links in txt file into one tabbed surf + +# dependencies: surf, osurf, dmenu + +# $1: file path for non interactive use +if [ -z "$1" ] +then + d="$HOME/dl/txtabs" + f="$(find "$d" -type f -printf '%f\n' | dmenu)" + [ "$f" ] || exit 1 + f="$d"/"$f" +else + [ -f "$1" ] || exit 1 + f="$1" +fi + +winid="$(osurf "$(head -n 1 "$f")")" +tail -n +2 "$f" | while read -r url; + do surf -e "$winid" "$url" & + done diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index fdd9d17..ddc605a 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -164,9 +164,6 @@ alias wtip='wt ip -c -brief addr' alias fusephone='sshfs myphone: /media/phone' alias ttyper='ttyper -l english1000' -alias wgup='doas wg-quick up wg0' -alias wgdown='doas wg-quick down wg0' - # NPM alias npi="npm init --yes" diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index 8e51135..1b69fbd 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -306,7 +306,7 @@ gdown () { } # toggle wireguard vpn on $1 -> interface -wgtoggle() { +wgt() { d="${1:-wg0}" ip -br a | awk '{print $1}' | grep "$d" > /dev/null && doas wg-quick down "$d" || diff --git a/config/essentials/vis/plugins/vis-snippets/init.lua b/config/essentials/vis/plugins/vis-snippets/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index a424613..1813888 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -5,6 +5,7 @@ require('vis') require('plugins/vis-cursors') require('plugins/vis-title') +require('plugins/vis-snippets') ------------------------------------ --- EVENTS -- cgit v1.2.3 From cbbaf8cb1e3e0f8113104d8234bb479430f27dff Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 20 Jun 2024 12:15:46 +0200 Subject: checkpoint --- bin/common/gt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/common/gt b/bin/common/gt index bdbd00f..53d2cab 100755 --- a/bin/common/gt +++ b/bin/common/gt @@ -7,7 +7,8 @@ # - $EDITOR: -e # - herbe (optional): -s -repos="${XDG_DATA_HOME:-$HOME}"/git-track.txt +repos=$HOME/sync/share/git-track.txt +# prevent file not found errors touch "$repos" help() { @@ -92,18 +93,27 @@ do printf '%s\n' "$r" >> "$repos" >&2 printf 'added.\n' ;; - c) repos_cmd "$OPTARG" ;; - s) status=1 ;; + c) f_command=1; f_arg="$OPTARG" ;; + s) f_status=1 ;; l) cat "$repos" ;; e) $EDITOR "$repos" ;; f) repos="$OPTARG" ;; - T) help ;; + h) help ;; :) >&2 printf -- '-%s requires argument\n' "$OPTARG"; exit 1 ;; ?) >&2 printf -- 'Invalid option: -%s\n' "$OPTARG"; exit 1 ;; esac done -if [ "$status" ] +# commands hereafter must happen in order + +[ "$(wc -l < "$repos")" -gt 0 ] || exit 0 + +if [ "$f_command" ] +then + repos_cmd "$f_arg" +fi + +if [ "$f_status" ] then status which herbe > /dev/null 2>&1 && -- cgit v1.2.3 From 4775688e796faece72c6621bcd94f6eb4ebac5ff Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 20 Jun 2024 12:18:46 +0200 Subject: checkpoint --- bin/guiscripts/osurf-txt | 18 ++++++++++++++++++ bin/guiscripts/osurftxt | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100755 bin/guiscripts/osurf-txt delete mode 100755 bin/guiscripts/osurftxt (limited to 'bin') diff --git a/bin/guiscripts/osurf-txt b/bin/guiscripts/osurf-txt new file mode 100755 index 0000000..9a1d4f4 --- /dev/null +++ b/bin/guiscripts/osurf-txt @@ -0,0 +1,18 @@ +#!/bin/sh + +# open a link from a txt file in surf + +# dependencies: surf, osurf, dmenu + +winid="$1" +>&2 printf 'winid: %s\n' "$winid" +tabs="$HOME/dl/txtabs" + +f="$(find "$tabs" -type f -printf '%f\n' | dmenu -c)" +[ "$f" ] || exit 1 +f="$tabs"/"$f" +>&2 printf 'f: %s\n' "$f" + +url="$(dmenu -c < "$f")" + +printf 'loaduri %s' "$url" > $HOME/.config/surf/fifo/$winid diff --git a/bin/guiscripts/osurftxt b/bin/guiscripts/osurftxt deleted file mode 100755 index 9a1d4f4..0000000 --- a/bin/guiscripts/osurftxt +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# open a link from a txt file in surf - -# dependencies: surf, osurf, dmenu - -winid="$1" ->&2 printf 'winid: %s\n' "$winid" -tabs="$HOME/dl/txtabs" - -f="$(find "$tabs" -type f -printf '%f\n' | dmenu -c)" -[ "$f" ] || exit 1 -f="$tabs"/"$f" ->&2 printf 'f: %s\n' "$f" - -url="$(dmenu -c < "$f")" - -printf 'loaduri %s' "$url" > $HOME/.config/surf/fifo/$winid -- cgit v1.2.3 From f3ca3f8988c2af29c8d13b5336d1bfefb3e36c81 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 20 Jun 2024 12:46:19 +0200 Subject: fix error on multiple branches --- bin/common/gt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/common/gt b/bin/common/gt index 53d2cab..c679b23 100755 --- a/bin/common/gt +++ b/bin/common/gt @@ -5,7 +5,6 @@ # dependencies: # - git # - $EDITOR: -e -# - herbe (optional): -s repos=$HOME/sync/share/git-track.txt # prevent file not found errors @@ -47,7 +46,8 @@ status() { >&2 printf '\r\033[0K' status="$(git status --porcelain 2> /dev/null | awk '{print $1}' | uniq | tr -d '\n')" - remote="$(git branch -v 2>/dev/null | sed 's/ahead/↑/;s/behind/↓/;s/[^↓↑]*//g')" + remote="$(git branch -v 2>/dev/null | + sed '/^*/!d;s/ahead/↑/;s/behind/↓/;s/[^↓↑]*//g')" printf '%s %s %s\n' "$repo_pretty" "$status" "$remote" done < "$repos" @@ -116,6 +116,6 @@ fi if [ "$f_status" ] then status - which herbe > /dev/null 2>&1 && - eval "herbe $(status | sed 's/"/\"/g;s/.*/"&"/' | tr '\n' ' ')" & fi + +# eval "herbe $(status | sed 's/"/\"/g;s/.*/"&"/' | tr '\n' ' ')" -- cgit v1.2.3 From 41d3ecdd5245c8c3f8adaa76bbdca24eacd9e007 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 20 Jun 2024 21:18:38 +0200 Subject: checkpoint --- bin/extra/clock | 4 +++- config/essentials/vis/plugins/init.lua | 2 ++ config/essentials/vis/visrc.lua | 4 +--- config/extra/mutt/.gitignore | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 config/essentials/vis/plugins/init.lua (limited to 'bin') diff --git a/bin/extra/clock b/bin/extra/clock index fdffae0..bd6efd2 100755 --- a/bin/extra/clock +++ b/bin/extra/clock @@ -7,7 +7,8 @@ then printf 'start,end,message\n' > "$clocks" fi -if [ "$1" = "-c" ] +# print clocks file prettily +if [ "$1" = "-p" ] then # empty [ "$(wc -l < "$clocks")" -eq 1 ] && exit @@ -23,6 +24,7 @@ then exit fi +# edit clocks file in $EDITOR if [ "$1" = "-e" ] then $EDITOR "$clocks" diff --git a/config/essentials/vis/plugins/init.lua b/config/essentials/vis/plugins/init.lua new file mode 100644 index 0000000..80c9280 --- /dev/null +++ b/config/essentials/vis/plugins/init.lua @@ -0,0 +1,2 @@ +require("plugins.vis-cursors") +require("plugins.vis-title") diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 1813888..81e09eb 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -3,9 +3,7 @@ ------------------------------------ require('vis') -require('plugins/vis-cursors') -require('plugins/vis-title') -require('plugins/vis-snippets') +require('plugins') ------------------------------------ --- EVENTS diff --git a/config/extra/mutt/.gitignore b/config/extra/mutt/.gitignore index 5e46596..ad7bbfd 100644 --- a/config/extra/mutt/.gitignore +++ b/config/extra/mutt/.gitignore @@ -1 +1,2 @@ -cache \ No newline at end of file +cache +mailboxes -- cgit v1.2.3 From 3145010306902a8b9e0a5863527837aa963afef5 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Fri, 21 Jun 2024 22:37:33 +0200 Subject: checkpoint --- bin/common/askpass | 13 +++++++++++++ bin/menuscripts/mpass | 2 +- config/essentials/shell/functions.sh | 14 -------------- config/essentials/vis/visrc.lua | 21 ++++++++++++++++++++- config/home/.zshenv | 3 +++ 5 files changed, 37 insertions(+), 16 deletions(-) create mode 100755 bin/common/askpass (limited to 'bin') diff --git a/bin/common/askpass b/bin/common/askpass new file mode 100755 index 0000000..2725dbf --- /dev/null +++ b/bin/common/askpass @@ -0,0 +1,13 @@ +#!/bin/sh + +# We can figure out the password for the key based on $1 +# which is in the following form: +# Enter passphrase for key 'path/to/key': +# The point is to retrieve the path and use the final name of the key +# find the according password. +key="$(printf '%s\n' "$1" | + cut -f 2 -d \' | + awk -F '/' '{print $NF}')" +pass="keys/$(hostname)/ssh/$key" + +pass show "$pass" | head -n 1 diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass index 7348321..f513b16 100755 --- a/bin/menuscripts/mpass +++ b/bin/menuscripts/mpass @@ -14,7 +14,7 @@ list_pswds() while [ -d "$store/$file" ] do - choice="$(list_pswds "$store/$file" | dmenu -c -g 4 -l 4)" + choice="$(list_pswds "$store/$file" | commander -c)" [ "$choice" ] || exit 1 [ -z "$file" ] && file="$choice" || file="$file/$choice" done diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index 1b69fbd..27eb33e 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -364,17 +364,3 @@ ffconcat () { ffmpeg -y -f concat -safe 0 -i $tmp -c copy "$1" rm $tmp } - -# wrap ssh and add key if exists -ssh() { - if [ "$#" -gt 1 ] - then - /usr/bin/ssh $@ - return - fi - - grep -E "Host\s+$1" $HOME/.ssh/config > /dev/null 2>&1 && - keyadd "$1" > /dev/null 2>&1 - /usr/bin/ssh "$1" -} - diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 7847784..e35b436 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -125,9 +125,28 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a if win.syntax == "bash" then map_keys( m.NORMAL, - " v", + ";p", "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/", "Print variable" ) + map_keys( + m.NORMAL, + ";v", + "V:x/^(\\s*)(.+)$/ c/\\1\"$(\\2)\"/", + "Surround in variable" + ) + map_keys( + m.NORMAL, + ";|", + "V:x/\\| / c/|\n\t/", + "Wrap one-line multi pipe command" + ) + map_keys( + m.NORMAL, + ";e", + "V:x/^(\\s*)(.+)$/ c/\\1[ \"\\2\" ] || exit 1/", + "Condition exit if empty" + ) + end end) diff --git a/config/home/.zshenv b/config/home/.zshenv index a87f01d..34a7c2f 100644 --- a/config/home/.zshenv +++ b/config/home/.zshenv @@ -96,3 +96,6 @@ export PATH="$PATH:$GOPATH/bin" export PLAN9=/usr/lib/plan9 export PATH="$PATH:$PLAN9/bin" + +export SSH_ASKPASS=askpass +export SSH_ASKPASS_REQUIRE=prefer -- cgit v1.2.3