diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-04-15 17:37:53 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-04-15 17:37:53 +0200 |
commit | 25a2605405d8ec7645d0664914c3b7290745afec (patch) | |
tree | 8afe0d8828a3909bfe2774385c8bebc039cf6d6e | |
parent | c9a06111585c189607ff1e81b77bb32f0a25a992 (diff) |
synced
-rwxr-xr-x | bin/extra/rek | 16 | ||||
-rwxr-xr-x | bin/extra/upds | 51 | ||||
-rwxr-xr-x | bin/extra/usbtoggle | 25 | ||||
-rwxr-xr-x | bin/extra/wipe | 4 | ||||
-rwxr-xr-x | bin/extra/ytplay | 2 | ||||
-rwxr-xr-x | bin/guiscripts/clipo | 2 | ||||
-rwxr-xr-x | bin/menuscripts/mpass-otp | 4 | ||||
-rwxr-xr-x | config/X/x11/xinitrc | 1 | ||||
-rw-r--r-- | config/common/mpv/input.conf | 4 | ||||
-rw-r--r-- | config/essentials/shell/aliases.sh | 5 | ||||
-rw-r--r-- | config/essentials/shell/functions.sh | 4 | ||||
-rw-r--r-- | config/essentials/starship.toml | 13 | ||||
-rw-r--r-- | config/essentials/zsh/.zshrc | 12 | ||||
-rw-r--r-- | config/essentials/zsh/widgets.zsh | 11 | ||||
-rw-r--r-- | config/home/.zshenv | 3 |
15 files changed, 136 insertions, 21 deletions
diff --git a/bin/extra/rek b/bin/extra/rek new file mode 100755 index 0000000..b5baac7 --- /dev/null +++ b/bin/extra/rek @@ -0,0 +1,16 @@ +#!/bin/sh + +# Record desktop with ffmpeg, strip metadata and use mp4 for relative small file size +# copy the path of the output file to the system clipboard for sharing +out="out.mp4" + +# with audio +if [ "$1" = "-a" ] +then + ffmpeg -y -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+0,0 -f pulse -ac 2 -i default -map 0:v -map 0:a? -map_metadata -1 -map_metadata:s:v -1 -map_metadata:s:a -1 -map_chapters -1 -disposition 0 "$out" +else + ffmpeg -y -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+0,0 -map 0:v -map 0:a? -map_metadata -1 -map_metadata:s:v -1 -map_metadata:s:a -1 -map_chapters -1 -disposition 0 "$out" +fi + +# copy output path +readlink -f "$out" | clipp diff --git a/bin/extra/upds b/bin/extra/upds new file mode 100755 index 0000000..38648ed --- /dev/null +++ b/bin/extra/upds @@ -0,0 +1,51 @@ +#!/bin/sh + +if [ "$1" = "install" ] +then + hook="/etc/pacman.d/hooks/upds.hook" + if [ "$(id -u)" -ne 0 ] + then + >&2 printf 'Please run as root.\n'; exit 1 + fi + + if [ -f "$hook" ] + then + >&2 printf 'Hook already installed.\n'; exit 1 + fi + + # Install the hook + cat <<EOF > "$hook" +# Hook for keeping available updates in sync after upgrade +# relies on 'upds' +[Trigger] +Operation = Upgrade +Type = Package +Target = * +[Action] +Description = Sync upds +When = PostTransaction +Exec = /usr/bin/sh -c '/usr/bin/kill -s USR1 "\$(/usr/bin/pgrep upds | /usr/bin/head -n 1)"' +EOF + >&2 printf 'Installed.\n' + + exit +fi + +count_updates() { checkupdates | wc -l > ~/.cache/updates; } + +# Periodically count updates in background +( + while true + do + count_updates + sleep 60m + done +) & + +# update on USR1 signal +trap count_updates USR1 + +# wait for signal +while true +do sleep 1s +done diff --git a/bin/extra/usbtoggle b/bin/extra/usbtoggle new file mode 100755 index 0000000..7adb2a2 --- /dev/null +++ b/bin/extra/usbtoggle @@ -0,0 +1,25 @@ +#!/bin/sh + +# toggle an usb device + +# dependencies +# - lsusb (to list usb devices) +# - commander (menu command) +# - doas (to run as root) + +device="$(lsusb | fzf)" +[ "$device" ] || exit 1 +# get vendor id +d=${device#*: * } +v=${d%%:*} +# get product id +d=${device#*:*:} +p=${d%% *} + +# find path by uzing vendor and product IDs +file="$(grep -l "$p" $(grep -l "$v" /sys/bus/usb/devices/*/idVendor | + sed 's/idVendor/idProduct/') | + sed 's/idProduct$/authorized/')" + +echo 0 | doas tee "$file" +echo 1 | doas tee "$file" diff --git a/bin/extra/wipe b/bin/extra/wipe index ec2abe9..6006b8e 100755 --- a/bin/extra/wipe +++ b/bin/extra/wipe @@ -2,8 +2,8 @@ [ 0 -eq "$#" ] && >&2 echo 'usage: wipe <file>' && exit 1 [ ! -f "$1" ] && [ ! -d "$1" ] && >&2 echo "'$1' not found." && exit 1 -confirm "sure?" || exit 1 ->&2 printf "\n" +printf "sure? " +[ "$(head -n 1)" != "y" ] && exit 1 find "$1" -type f -print0 | xargs -0I{} shred -uz "{}" && diff --git a/bin/extra/ytplay b/bin/extra/ytplay new file mode 100755 index 0000000..b5c1a8c --- /dev/null +++ b/bin/extra/ytplay @@ -0,0 +1,2 @@ +#!/bin/sh +yt-dlp -o - "$(ytlink)" | mpv - diff --git a/bin/guiscripts/clipo b/bin/guiscripts/clipo index 39994f9..078cc13 100755 --- a/bin/guiscripts/clipo +++ b/bin/guiscripts/clipo @@ -1,6 +1,6 @@ #!/bin/sh [ "$1" = "-p" ] && arg='primary' if [ "$WAYLAND_DISPLAY" ] -then wl-paste -n ${1} +then wl-paste -n "$1" else xclip -o -selection "${arg:-clipboard}" -r fi diff --git a/bin/menuscripts/mpass-otp b/bin/menuscripts/mpass-otp index 86690d3..52d1341 100755 --- a/bin/menuscripts/mpass-otp +++ b/bin/menuscripts/mpass-otp @@ -1,6 +1,6 @@ #!/bin/sh -pass="$(find "$PASSWORD_STORE_DIR"/keys/otp -name "*.gpg" -printf '%f\n' | - sed 's/\.gpg$//' | +pass="$(find "$PASSWORD_STORE_DIR"/keys/otp -iname "*.gpg" | + sed "/^\./d;s#^$PASSWORD_STORE_DIR/keys/otp/##;s/\.gpg$//" | commander -c)" [ "$pass" ] || exit 1 pass otp -c keys/otp/"$pass" diff --git a/config/X/x11/xinitrc b/config/X/x11/xinitrc index c9750df..bc1824a 100755 --- a/config/X/x11/xinitrc +++ b/config/X/x11/xinitrc @@ -27,6 +27,7 @@ setxkbmap us -option ctrl:swapcaps,altwin:menu_win -variant colemak gammastep -m randr & # dunst & slstatus & +upds & emacs --daemon & eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg,ssh)" unclutter --timeout 3 --jitter 50 -b diff --git a/config/common/mpv/input.conf b/config/common/mpv/input.conf index 7e16c16..1d3a486 100644 --- a/config/common/mpv/input.conf +++ b/config/common/mpv/input.conf @@ -226,3 +226,7 @@ alt+c script-message cycle-commands 'show-text "${chapter-metadata/title}" 10000 # display information and statistics i script-binding stats/display-stats-toggle + +x add audio-delay 0.100 # change audio/video sync by delaying the audio +X add audio-delay -0.100 # change audio/video sync by shifting the audio earlier +ctrl+x set audio-delay 0 diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index 931f8bb..9b8bed0 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -144,6 +144,7 @@ alias mdb='mariadb -u admin -ppass admindb' alias mdbw='mariadb -h 0.0.0.0 -u padmin -pbulbizarre padmindb' alias mdbwa='mariadb -h 10.3.50.5 -u padmin -pbulbizarre padmindb' alias tmux='pgrep tmux && tmux attach || tmux new-session' +alias wd='dict' # ssh alias sha='ssh-add' @@ -185,7 +186,7 @@ alias gdate='date +%y_%m_%d-%T' alias tpid='tail -f /dev/null --pid' alias pwdcp='pwd | clipp' alias gw="grep -ri" -alias srcsupd='echo ~/src/{installdrier,dotfiles,password-store} ~/proj/suckless/*/ ~/proj/personal/scripts/*/ ~/.config/emacs | supd' +alias srcsupd='echo ~/src/{installdrier,dotfiles,password-store} ~/proj/suckless/*/ ~/proj/personal/scripts/*/ ~/.config/emacs ~/.config/nvim | supd' # systemctl aliases alias smc='systemctl' @@ -290,7 +291,6 @@ alias ffwin='hyprctl clients -j | jq '\''.[].pid'\'' | fzf --preview "hyprctl cl alias pff='find ${PASSWORD_STORE_DIR:=~/src/password-store/} -name "*.gpg" | sed -e "s@$PASSWORD_STORE_DIR/@@" -e '\''s/\.gpg$//'\'' | fzf | xargs pass show -c' alias fzps='fzf --print0 | xargs -0I{}' alias ytdl='yt-dlp --restrict-filenames --embed-chapters -f "b" -S "res:1080" -P "$HOME/vids/youtube/" -o "%(channel)s/%(title)s.%(ext)s"' -alias ytplay='mpv "$(ytlink)"' # emacs aliases alias emacsd='emacs --daemon' @@ -330,3 +330,4 @@ 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 brs='$BROWSER' diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index ce02490..250d049 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -69,8 +69,8 @@ trcp() { scp "$1" db:/media/basilisk/downloads/transmission/torrents/; } rln() { ln -s "$(readlink -f "$1")" "$2"; } getgit() { git clone git@db:"$1"; } esc() { eval "$EDITOR '$(which $1)'"; } -delfile() { curl "${2:-https://upfast.cronyakatsuki.xyz/delete/$1}"; } -upfile() { curl -F "file=@\"$1\"" "${2:-https://0x0.st}"; } +delfile() { curl -s "${2:-https://upfast.cronyakatsuki.xyz/delete/$1}"; } +upfile() { curl -s -F "file=@\"$1\"" "${2:-https://0x0.st}"; } to_webm() { ffmpeg -y -i "$1" -vcodec libvpx -cpu-used -12 -deadline realtime "${1%.*}".webm; } ngenable() { ln -sf /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/; } remove_audio() { ffmpeg -i "$1" -cpu-used -$(nproc) -deadline realtime -c copy -an "${2:-out.mp4}"; } diff --git a/config/essentials/starship.toml b/config/essentials/starship.toml index 0a9faaf..cd5832f 100644 --- a/config/essentials/starship.toml +++ b/config/essentials/starship.toml @@ -2,11 +2,12 @@ # Inserts a blank line between shell prompts add_newline = false -format = ' [\[$username@$hostname\]](bg:#000000) $all' +# format = ' ${custom.upds}' +format = ' [\[$username@$hostname\]](bg:#000000) ${custom.upds}$all' right_format = """$status""" [character] -format = ' [❯](bold bright-yellow) ' +format = ' \$ ' [username] style_root = "bold red" @@ -30,3 +31,11 @@ min_time = 500 [status] format = '($status)' disabled = false + +[custom.upds] +command = 'cat ~/.cache/updates' # shows output of command +# detect_files = ['foo'] # can specify filters but wildcards are not supported +when = ''' test "$(cat ~/.cache/updates)" -gt 0''' +symbol = '📦' +format = '$output$symbol ' + diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index cb5e120..ccec6d5 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -16,10 +16,6 @@ fi autoload -U select-word-style autoload -z edit-command-line zle -N edit-command-line -autoload -Uz surround -zle -N delete-surround surround -zle -N add-surround surround -zle -N change-surround surround ### Source files . $XDG_CONFIG_HOME/shell/functions.sh @@ -49,8 +45,8 @@ plug "zsh-users/zsh-history-substring-search" plug "MichaelAquilina/zsh-auto-notify" export AUTO_NOTIFY_TITLE="zsh" -export AUTO_NOTIFY_BODY="<b>%command</b> [%exit_code]" -AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop") +export AUTO_NOTIFY_BODY="%command [%exit_code]" +AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis") # Substring search settings export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="bg=blue,fg=black,bold" @@ -86,9 +82,6 @@ fi ### Keybinds bindkey -v -bindkey -a cs change-surround -bindkey -a ds delete-surround -bindkey -a ys add-surround bindkey -M visual S add-surround bindkey "^A" beginning-of-line bindkey "^E" end-of-line @@ -103,6 +96,7 @@ bindkey "^Xe" edit-command-line bindkey "^[." insert-last-word bindkey "^['" quote-line bindkey '\ea' autosuggest-toggle +bindkey '^Xp' push-input ## Move around using h j k l in completion menu zmodload zsh/complist bindkey -M menuselect 'h' vi-backward-char diff --git a/config/essentials/zsh/widgets.zsh b/config/essentials/zsh/widgets.zsh index c8b24f7..233ea65 100644 --- a/config/essentials/zsh/widgets.zsh +++ b/config/essentials/zsh/widgets.zsh @@ -1,4 +1,4 @@ -# surround line in variable +# Surround line in variable surround_in_var() { BUFFER=" \"\$($BUFFER)\"" @@ -7,3 +7,12 @@ surround_in_var() zle -N surround_in_var bindkey '\ev' surround_in_var +# Insert output from the previous command +zmodload -i zsh/parameter +insert-last-command-output() { + LBUFFER+="$(eval $history[$((HISTCMD-1))])" +} +zle -N insert-last-command-output +bindkey "^Xl" insert-last-command-output + +# diff --git a/config/home/.zshenv b/config/home/.zshenv index 5d12e62..745f8bf 100644 --- a/config/home/.zshenv +++ b/config/home/.zshenv @@ -64,6 +64,9 @@ export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS' --color=info:#b48ead,prompt:#bf6069,pointer:#b48dac --color=marker:#a3be8b,spinner:#ebcb8b,header:#a3be8b' +# Colored manpages +export MANPAGER="less -R --use-color -Dd+r -Du+b" +export MANROFFOPT="-P -c" export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/bin:$PATH" |