Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2023-06-04 00:06:31 -04:00
parent 64d9ae79aa
commit 160e9ece27
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
19 changed files with 819 additions and 792 deletions

View File

@ -19,5 +19,5 @@ PERL_MM_OPT="INSTALL_BASE=/home/cobra/perl5"; export PERL_MM_OPT;
. ~/.devspec . ~/.devspec
if [[ $(tty) == /dev/tty2 ]]; then if [[ $(tty) == /dev/tty2 ]]; then
exec $WM exec $WM
fi fi

277
.bashrc
View File

@ -18,7 +18,7 @@ export GPG_TTY=$(tty)
export MANPATH=/run/current-system/profile/share/man:/home/cobra/.guix-profile/share/man:/run/current-system/profile/share/man:/home/cobra/.guix-home/profile/share/man export MANPATH=/run/current-system/profile/share/man:/home/cobra/.guix-profile/share/man:/run/current-system/profile/share/man:/home/cobra/.guix-home/profile/share/man
clear() { clear() {
printf '\033c' # faster than ncurses clear by a lot printf '\033c' # faster than ncurses clear by a lot
} }
# Other aliases # Other aliases
@ -39,7 +39,7 @@ alias dico="dico -d en-wiktionary"
# Random string (passwords) # Random string (passwords)
randstr() { randstr() {
tr -cd '[:graph:]' </dev/urandom | head -c ${1:-256} tr -cd '[:graph:]' </dev/urandom | head -c ${1:-256}
} }
# Get CPU usage # Get CPU usage
@ -52,233 +52,226 @@ update() { $PRIV sh -c "$UPDATE"; }
# Im too lazy to type # Im too lazy to type
copy() { copy() {
printf "%s" "$(</dev/stdin)" > >($COPY_COMMAND) printf "%s" "$(</dev/stdin)" > >($COPY_COMMAND)
} }
# URL-encode stdin # URL-encode stdin
urlencode() { urlencode() {
LC_COLLATE_OLD=$LC_COLLATE LC_COLLATE_OLD=$LC_COLLATE
LC_COLLATE=C LC_COLLATE=C
local TEXT="$(</dev/stdin)" local TEXT="$(</dev/stdin)"
local LENGTH="${#TEXT}" local LENGTH="${#TEXT}"
for (( i = 0; i < LENGTH; i++ )); do for (( i = 0; i < LENGTH; i++ )); do
local c="${TEXT:$i:1}" local c="${TEXT:$i:1}"
case $c in case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;; [a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;; *) printf '%%%02X' "'$c" ;;
esac esac
done done
LC_COLLATE=$LC_COLLATE_OLD LC_COLLATE=$LC_COLLATE_OLD
} }
diffhome() { find . -type f -regex '\./\.[^g].*' -exec diff -q ~/{} {} 2> /dev/null \;; } diffhome() { find . -type f -regex '\./\.[^g].*' -exec diff -q ~/{} {} 2> /dev/null \;; }
fixdh() { fixdh() {
diffhome | while read -r _ SRC _ DEST _; do diffhome | while read -r _ SRC _ DEST _; do
cp $SRC $DEST; cp $SRC $DEST;
done; done;
} }
strlen() { strlen() {
N=$(wc -c <<< "$*") N=$(wc -c <<< "$*")
((N--)) ((N--))
printf '%u printf '%u\n' "$N"
' "$N"
} }
uppweb() { uppweb() {
ssh vern.cc 'cd ~/public_html; git pull' ssh vern.cc 'cd ~/public_html; git pull'
} }
caption() { caption() {
[ -z "$3" ] && { [ -z "$3" ] && {
echo "Usage: caption [input] [output] [text...]" echo "Usage: caption [input] [output] [text...]"
return 1 return 1
} }
local FILE="$1" local FILE="$1"
local OUT="$2" local OUT="$2"
shift 2 shift 2
local TEXT="$*" local TEXT="$*"
local WIDTH="$(identify -format "%[w] local WIDTH="$(identify -format "%[w]\n" "$FILE" | head -n1)"
" "$FILE" | head -n1)" local HEIGHT="$(identify -format "%[h]\n" "$FILE" | head -n1)"
local HEIGHT="$(identify -format "%[h] local FONT_SIZE="$(((HEIGHT+WIDTH)/20))"
" "$FILE" | head -n1)" convert -gravity north \( -size "${WIDTH}x" -pointsize "$FONT_SIZE" -font 'Liberation-Sans-Bold' caption:"$TEXT" -gravity Center -extent "${WIDTH}x" \) "$FILE" -append "$OUT"
local FONT_SIZE="$(((HEIGHT+WIDTH)/20))"
convert -gravity north \( -size "${WIDTH}x" -pointsize "$FONT_SIZE" -font 'Liberation-Sans-Bold' caption:"$TEXT" -gravity Center -extent "${WIDTH}x" \) "$FILE" -append "$OUT"
} }
captionvid() { captionvid() {
[ -z "$3" ] && { [ -z "$3" ] && {
echo "Usage: captionvid [input] [output] [text...]" echo "Usage: captionvid [input] [output] [text...]"
return 1 return 1
} }
rm /tmp/caption.*.png rm /tmp/caption.*.png
FPS="$(ffmpeg -i "$1" 2>&1 |grep fps | sed 's/.* \([0-9]\+\) fps.*/\1/')" FPS="$(ffmpeg -i "$1" 2>&1 |grep fps | sed 's/.* \([0-9]\+\) fps.*/\1/')"
IN="$1" IN="$1"
OUT="$2" OUT="$2"
shift 2 shift 2
ffmpeg -i "$IN" "/tmp/caption.%02d.png" ffmpeg -i "$IN" "/tmp/caption.%02d.png"
for i in /tmp/caption.*; do for i in /tmp/caption.*; do
caption "$i" "$i-new.png" "$*" caption "$i" "$i-new.png" "$*"
done done
ffmpeg -framerate $FPS -i "/tmp/caption.%02d.png-new.png" "$OUT" ffmpeg -framerate $FPS -i "/tmp/caption.%02d.png-new.png" "$OUT"
rm /tmp/caption.*.png rm /tmp/caption.*.png
} }
topbottom() { topbottom() {
[ -z "$3" ] && { [ -z "$3" ] && {
echo "Usage: caption [input] [output] [text...]" echo "Usage: caption [input] [output] [text...]"
return 1 return 1
} }
local FILE="$1" local FILE="$1"
local OUT="$2" local OUT="$2"
shift 2 shift 2
local WIDTH="$(identify -format "%[w] local WIDTH="$(identify -format "%[w]\n" "$FILE" | head -n1)"
" "$FILE" | head -n1)" local HEIGHT="$(identify -format "%[h]\n" "$FILE" | head -n1)"
local HEIGHT="$(identify -format "%[h] local FONT_SIZE="$(((HEIGHT+WIDTH)/20))"
" "$FILE" | head -n1)" convert -size "${WIDTH}x" -stroke black -strokewidth 3 -fill white -pointsize "$FONT_SIZE" -font 'Liberation-Sans-Bold' -gravity Center -extent "${WIDTH}x" -gravity north \( -annotate +0+0 "$1" \) -gravity south \( -annotate +0+0 "$2" \) "$FILE" -append "$OUT"
local FONT_SIZE="$(((HEIGHT+WIDTH)/20))"
convert -size "${WIDTH}x" -stroke black -strokewidth 3 -fill white -pointsize "$FONT_SIZE" -font 'Liberation-Sans-Bold' -gravity Center -extent "${WIDTH}x" -gravity north \( -annotate +0+0 "$1" \) -gravity south \( -annotate +0+0 "$2" \) "$FILE" -append "$OUT"
} }
topbottomvid() { topbottomvid() {
[ -z "$3" ] && { [ -z "$3" ] && {
echo "Usage: captionvid [input] [output] [text...]" echo "Usage: captionvid [input] [output] [text...]"
return 1 return 1
} }
rm /tmp/caption.*.png rm /tmp/caption.*.png
FPS="$(ffmpeg -i "$1" 2>&1 |grep fps | sed 's/.* \([0-9]\+\) fps.*/\1/')" FPS="$(ffmpeg -i "$1" 2>&1 |grep fps | sed 's/.* \([0-9]\+\) fps.*/\1/')"
IN="$1" IN="$1"
OUT="$2" OUT="$2"
shift 2 shift 2
ffmpeg -i "$IN" "/tmp/caption.%02d.png" ffmpeg -i "$IN" "/tmp/caption.%02d.png"
for i in /tmp/caption.*; do for i in /tmp/caption.*; do
topbottom "$i" "$i-new.png" "$1" "$2" topbottom "$i" "$i-new.png" "$1" "$2"
done done
ffmpeg -framerate $FPS -i "/tmp/caption.%02d.png-new.png" "$OUT" ffmpeg -framerate $FPS -i "/tmp/caption.%02d.png-new.png" "$OUT"
rm /tmp/caption.*.png rm /tmp/caption.*.png
} }
subcipher() { subcipher() {
local COLOR PERM L1 line grep word local COLOR PERM L1 line grep word
if [ $# -lt 3 ]; then if [ $# -lt 3 ]; then
if [ $# -lt 2 ] || [[ "$1" != "0" && "$1" != "1" ]]; then if [ $# -lt 2 ] || [[ "$1" != "0" && "$1" != "1" ]]; then
printf "Usage: [0|1] subcipher file [string...] printf "Usage: [0|1] subcipher file [string...]\n"
" return 1
return 1 fi
fi fi
fi COLOR="$1"
COLOR="$1" shift
shift PERM="$1"
PERM="$1" shift
shift [ -z "$*" ] && set -- "$(</dev/stdin)"
[ -z "$*" ] && set -- "$(</dev/stdin)" L1="$(head -1 "$PERM")"
L1="$(head -1 "$PERM")" while read -r line; do
while read -r line; do tr "${L1^^}${L1}" "${line^^}${line}" <<< "$*"
tr "${L1^^}${L1}" "${line^^}${line}" <<< "$*" done < "$PERM" | while read -r line; do
done < "$PERM" | while read -r line; do for word in $line; do
for word in $line; do [ $COLOR -eq 1 ] && grep="$(grep --color=always -xF "$word" /etc/dictionaries-common/words)"
[ $COLOR -eq 1 ] && grep="$(grep --color=always -xF "$word" /etc/dictionaries-common/words)" printf %s "${grep:-$word} "
printf %s "${grep:-$word} " done
done printf '\n'
printf ' done
'
done
} }
playcd() { playcd() {
mpv --start=00:00:00.0000000 av://libcdio:/dev/cdrom --cache=yes mpv --start=00:00:00.0000000 av://libcdio:/dev/cdrom --cache=yes
} }
playdvd() { playdvd() {
mpv --start=00:00:00.0000000 dvd:///dev/sr0 --cache=yes mpv --start=00:00:00.0000000 dvd:///dev/sr0 --cache=yes
} }
gpginfo() { gpginfo() {
gpg --with-colons --import-options show-only --import gpg --with-colons --import-options show-only --import
} }
lc() { lc() {
fc -nl $HISTCMD | sed 's/^\s*//' fc -nl $HISTCMD | sed 's/^\s*//'
} }
baseto() { baseto() {
if [ $# -ge 3 ]; then if [ $# -ge 3 ]; then
local i="$1" local i="$1"
local o="$2" local o="$2"
shift 2 shift 2
bc <<< "obase=$o;$(($i#$*))" bc <<< "obase=$o;$(($i#$*))"
else else
local line i o n local line i o n
while read -r line; do while read -r line; do
read -r i o n <<< "$line" read -r i o n <<< "$line"
bc <<< "obase=$o;$(($i#$n))" bc <<< "obase=$o;$(($i#$n))"
done done
fi fi
} }
rebash() { . ~/.bashrc; } rebash() { . ~/.bashrc; }
bashrc() { "$EDITOR" ~/.bashrc && rebash; } bashrc() { "$EDITOR" ~/.bashrc && rebash; }
uplot() { uplot() {
ssh vern "${1:-/opt/gnuplot/users/gnuplot.sh}; cat /opt/gnuplot/users/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh vern "${1:-/opt/gnuplot/users/gnuplot.sh}; cat /opt/gnuplot/users/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
mnplot() { mnplot() {
ssh mythos "${1:-/opt/gnuplot/gnuplot.sh}; cat /opt/gnuplot/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh mythos "${1:-/opt/gnuplot/gnuplot.sh}; cat /opt/gnuplot/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
vnplot() { vnplot() {
ssh vern "${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh vern "${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
vpplot() { vpplot() {
ssh vern "${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh vern "${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
inplot() { inplot() {
ssh iceberg "${1:-~/gnuplot/gnuplot.sh}; cat ~/gnuplot/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh iceberg "${1:-~/gnuplot/gnuplot.sh}; cat ~/gnuplot/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
cnplot() { cnplot() {
ssh crescent "${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh crescent "${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
cpplot() { cpplot() {
ssh crescent "${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg ssh crescent "${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg" > ${1:-$(date -u -I)}.svg
} }
reconf() { reconf() {
$PRIV su - -c "guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm" $PRIV su - -c "guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm"
} }
hreconf() { hreconf() {
guix home reconfigure $HOME/.config/guix/home.scm guix home reconfigure $HOME/.config/guix/home.scm
} }
geng() { geng() {
< "$1" sed 's/\s*;.*//' | grep -ve '^$' -e '^T' | awk '{print "N"NR" "$0}' > "$2" < "$1" sed 's/\s*;.*//' | grep -ve '^$' -e '^T' | awk '{print "N"NR" "$0}' > "$2"
} }
mkmshex() { mkmshex() {
FILE="${1%.*}" FILE="${1%.*}"
microscheme "$1" microscheme "$1"
avr-gcc -B /run/current-system/profile/avr/lib/avr5 -mmcu="$2" -g -Os "$FILE".s -o "$FILE".elf avr-gcc -B /run/current-system/profile/avr/lib/avr5 -mmcu="$2" -g -Os "$FILE".s -o "$FILE".elf
avr-objcopy -Oihex "$FILE".o "$FILE".hex avr-objcopy -Oihex "$FILE".o "$FILE".hex
} }
uploadhex() { uploadhex() {
avrdude -C/run/current-system/profile/etc/avrdude.conf -v -p"$2" -carduino -P${3:-/dev/ttyS0} -U"flash:w:$1:i" avrdude -C/run/current-system/profile/etc/avrdude.conf -v -p"$2" -carduino -P${3:-/dev/ttyS0} -U"flash:w:$1:i"
} }
gshpkg() { gshpkg() {
local re='[(]?("([^"]*)"' local re='[\(]?\("([^"]*)"'
if [[ "$GUIX_ENVIRONMENT" ]]; then if [[ "$GUIX_ENVIRONMENT" ]]; then
local PACKAGES=($(while read -r line; do local PACKAGES=($(while read -r line; do
[[ "$line" =~ $re ]] && printf '%s ' "${BASH_REMATCH[1]}" [[ "$line" =~ $re ]] && printf '%s ' "${BASH_REMATCH[1]}"
done < $GUIX_ENVIRONMENT/manifest)) done < $GUIX_ENVIRONMENT/manifest))
echo ${PACKAGES[@]} echo ${PACKAGES[@]}
fi fi
} }

View File

@ -1,46 +1,58 @@
(define-module (cobra bin) (define-module (cobra bin)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (gnu packages base)
#:export (bin-torbrowser #:export (bin-torbrowser
bin-suspend-wrap bin-suspend-wrap
bin-suspend bin-suspend
bin-start-pipewire bin-start-pipewire
bin-screenshot bin-screenshot
bin-logout-wofi bin-logout-wofi
bin-lock bin-lock
bin-fss bin-fss
bin-beep-wrapper bin-beep-wrapper
bin-beep bin-beep
bin-backtick)) bin-backtick))
(define bin-torbrowser (define bin-torbrowser
(plain-file "bin-torbrowser" "\ (computed-file "bin-torbrowser"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
cd ~/.local/share/torbrowser/tor-browser/ cd ~/.local/share/torbrowser/tor-browser/
guix shell --check --pure --expression='(list (@@ (gnu packages gcc) gcc-11) \"lib\")' coreutils bash grep sed gcc-toolchain patchelf gtk+ dbus-glib libxt libevent openssl file alsa-lib << EOF guix shell --check --pure --expression='(list (@@ (gnu packages gcc) gcc-11) \"lib\")' coreutils bash grep sed gcc-toolchain patchelf gtk+ dbus-glib libxt libevent openssl file alsa-lib << \"EOF\" >" #$output "1
set -x set -x
cd Browser cd Browser
patchelf --set-interpreter \\$LIBRARY_PATH/ld-linux-x86-64.so.2 firefox.real patchelf --set-interpreter \\$LIBRARY_PATH/ld-linux-x86-64.so.2 firefox.real
patchelf --set-interpreter \\$LIBRARY_PATH/ld-linux-x86-64.so.2 TorBrowser/Tor/tor patchelf --set-interpreter \\$LIBRARY_PATH/ld-linux-x86-64.so.2 TorBrowser/Tor/tor
LD_LIBRARY_PATH=\\$LIBRARY_PATH ./start-tor-browser -v LD_LIBRARY_PATH=\\$LIBRARY_PATH ./start-tor-browser -v
EOF")) EOT" "\nEOF"))
(chmod #$output #o755))))
(define bin-suspend-wrap (define bin-suspend-wrap
(plain-file "bin-suspend-wrap" "\ (computed-file "bin-suspend-wrap"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
sudo ~/.local/bin/__suspend sudo ~/.local/bin/__suspend
while grep -v '\\[' /sys/power/state; do while grep -v '\\[' /sys/power/state; do
swaylock swaylock
break break
done")) done" "\nEOF"))
(chmod #$output #o755))))
(define bin-suspend (define bin-suspend
(plain-file "bin-suspend" "\ (computed-file "bin-suspend"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
echo mem > /sys/power/state")) echo mem > /sys/power/state" "\nEOF"))
(chmod #$output #o755))))
(define bin-start-pipewire (define bin-start-pipewire
(plain-file "bin-start-pipewire" "\ (computed-file "bin-start-pipewire"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
rm -rf /run/user/$UID/pulse rm -rf /run/user/$UID/pulse
@ -49,83 +61,95 @@ rm -rf /run/user/$UID/pulse
pipewire & pipewire &
pipewire-pulse & pipewire-pulse &
wireplumber &")) wireplumber &" "\nEOF"))
(chmod #$output #o755))))
(define bin-screenshot (define bin-screenshot
(plain-file "bin-screenshot" "\ (computed-file "bin-screenshot"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
if [ ! -d $HOME/Pictures/Screenshots ] if [ ! -d $HOME/Pictures/Screenshots ]
then then
mkdir -p $HOME/Pictures/Screenshots mkdir -p $HOME/Pictures/Screenshots
fi fi
fullscreen() { fullscreen() {
filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Fullscreen).png filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Fullscreen).png
grim $filename grim $filename
cat $filename | wl-copy \ cat $filename | wl-copy \
&& notify-send -i $filename \"Fullscreen Screenshot taken\" && notify-send -i $filename \"Fullscreen Screenshot taken\"
} }
selecting() { selecting() {
filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Selected).png filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Selected).png
grim -g \"$(slurp -b e3eaf699)\" $filename \ grim -g \"$(slurp -b e3eaf699)\" $filename \
&& notify-send -i $filename \"Selective Screenshot taken\" && notify-send -i $filename \"Selective Screenshot taken\"
cat $filename | wl-copy cat $filename | wl-copy
} }
wofirun() { wofirun() {
case \"$(printf \"fullscreen\\nselect\\n\" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )\" in case \"$(printf \"fullscreen\\nselect\\n\" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )\" in
'fullscreen')fullscreen;; 'fullscreen')fullscreen;;
'select')selecting;; 'select')selecting;;
esac esac
} }
helpscreen() { helpscreen() {
echo \"Usage: screenshot [-f] [-s] [-w] [-h] \" echo \"Usage: screenshot [-f] [-s] [-w] [-h] \"
echo \"Options:\" echo \"Options:\"
echo \"-f : Fullscreen screenshot\" echo \"-f : Fullscreen screenshot\"
echo \"-s : Select a region for the screenshot\" echo \"-s : Select a region for the screenshot\"
echo \"-w : Shows a wofi prompt for screenshot\" echo \"-w : Shows a wofi prompt for screenshot\"
echo \"-h : Shows this fucking help menu\" echo \"-h : Shows this fucking help menu\"
echo \"If no flags are selected then -f is chosen\" echo \"If no flags are selected then -f is chosen\"
} }
case $1 in case $1 in
-f)fullscreen;; -f)fullscreen;;
-s)selecting;; -s)selecting;;
-h)helpscreen;; -h)helpscreen;;
-w)wofirun;; -w)wofirun;;
*)fullscreen;; *)fullscreen;;
esac")) esac" "\nEOF"))
(chmod #$output #o755))))
(define bin-logout-wofi (define bin-logout-wofi
(plain-file "bin-logout-wofi" "\ (computed-file "bin-logout-wofi"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
case \"$(printf \"logout\\nreboot\\nshutdown\\nsleep\\n\" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )\" in case \"$(printf \"logout\\nreboot\\nshutdown\\nsleep\\n\" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )\" in
'logout') swaymsg exit;; 'logout') swaymsg exit;;
'sleep') ~/.local/bin/suspend ;; 'sleep') ~/.local/bin/suspend ;;
'reboot') sudo reboot ;; 'reboot') sudo reboot ;;
'shutdown') sudo poweroff ;; 'shutdown') sudo poweroff ;;
*) exit 1 ;; *) exit 1 ;;
esac")) esac" "\nEOF"))
(chmod #$output #o755))))
(define bin-lock (define bin-lock
(plain-file "bin-lock" "\ (computed-file "bin-lock"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
if ! ps aux | grep -v grep | grep swaylock; then if ! ps aux | grep -v grep | grep swaylock; then
# if [[ $(playerctl status) != \"Playing\" ]]; then # if [[ $(playerctl status) != \"Playing\" ]]; then
# swayidle -w timeout 600 'sudo ~/.local/bin/__suspend' & # swayidle -w timeout 600 'sudo ~/.local/bin/__suspend' &
# SUSPEND=$! # SUSPEND=$!
# fi # fi
swayidle -w timeout 15 'swaymsg \"output * dpms off\"' resume 'swaymsg \"output * dpms on\"' & swayidle -w timeout 15 'swaymsg \"output * dpms off\"' resume 'swaymsg \"output * dpms on\"' &
SCREENOFF=$! SCREENOFF=$!
swaylock swaylock
kill $SUSPEND $SCREENOFF kill $SUSPEND $SCREENOFF
fi")) fi" "\nEOF"))
(chmod #$output #o755))))
(define bin-fss (define bin-fss
(plain-file "bin-fss" "\ (computed-file "bin-fss"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
# made by aryak.vern.cc modified by cobra.vern.cc # made by aryak.vern.cc modified by cobra.vern.cc
if [[ -S \"/tmp/mpvfsfsock\" ]]; then if [[ -S \"/tmp/mpvfsfsock\" ]]; then
@ -133,32 +157,41 @@ if [[ -S \"/tmp/mpvfsfsock\" ]]; then
else else
mpv --input-ipc-server=/tmp/mpvfsfsock ~/.local/share/fss.ogg mpv --input-ipc-server=/tmp/mpvfsfsock ~/.local/share/fss.ogg
trap \"rm -rf /tmp/mpvfsfsock\" EXIT trap \"rm -rf /tmp/mpvfsfsock\" EXIT
fi")) fi" "\nEOF"))
(chmod #$output #o755))))
(define bin-beep-wrapper (define bin-beep-wrapper
(plain-file "bin-beep-wrapper" "\ (computed-file "bin-beep-wrapper"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
while sleep 1; do while sleep 1; do
## Battery beep ## Battery beep
if ls /sys/class/power_supply/BAT* &>/dev/null; then if ls /sys/class/power_supply/BAT* &>/dev/null; then
BAT0=$(</sys/class/power_supply/BAT0/capacity) BAT0=$(</sys/class/power_supply/BAT0/capacity)
if [[ $BAT0 -le 5 && -z \"$BEEPED\" && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then if [[ $BAT0 -le 5 && -z \"$BEEPED\" && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then
sudo ~/.local/bin/beep 9 sudo ~/.local/bin/beep 9
BEEPED=1 BEEPED=1
elif [[ $BAT0 -le 2 && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then elif [[ $BAT0 -le 2 && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then
sudo ~/.local/bin/beep 9 sudo ~/.local/bin/beep 9
BEEPED=0 BEEPED=0
fi fi
fi fi
done")) done" "\nEOF"))
(chmod #$output #o755))))
(define bin-beep (define bin-beep
(plain-file "bin-beep" "\ (computed-file "bin-beep"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env sh #!/usr/bin/env sh
echo $1 > /proc/acpi/ibm/beep")) echo $1 > /proc/acpi/ibm/beep" "\nEOF"))
(chmod #$output #o755))))
(define bin-backtick (define bin-backtick
(plain-file "bin-backtick" "\ (computed-file "bin-backtick"
#~(begin
(system (string-append #$coreutils "/bin/cat << \"EOF\" >" #$output "\n" "\
#!/usr/bin/env bash #!/usr/bin/env bash
cpu() { cpu() {
@ -166,11 +199,12 @@ cpu() {
} }
ram() { ram() {
free -h | sed '2!d' | (read _ _ used _; echo $used) free -h | sed '2!d' | (read _ _ used _; echo $used)
} }
bat() { bat() {
acpi -b | sed 's/Battery /BAT/' acpi -b | sed 's/Battery /BAT/'
} }
echo \"$(cpu)% $(ram) $(bat)\"")) echo \"$(cpu)% $(ram) $(bat)\"" "\nEOF"))
(chmod #$output #o755))))

View File

@ -10,35 +10,35 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [[ $HOSTNAME == pp ]]; then if [[ $HOSTNAME == pp ]]; then
PRIV=doas PRIV=doas
UPDATE=\"$PRIV sh -c 'apk update && apk upgrade -aiv && apk fix'\" UPDATE=\"$PRIV sh -c 'apk update && apk upgrade -aiv && apk fix'\"
COPY_COMMAND=\"wl-copy\" COPY_COMMAND=\"wl-copy\"
PASTE_COMMAND=\"wl-paste\" PASTE_COMMAND=\"wl-paste\"
WIFI=wlan0 WIFI=wlan0
WM=\"bash\" WM=\"bash\"
elif [[ $HOSTNAME == Xenon ]]; then elif [[ $HOSTNAME == Oganesson ]]; then
PRIV=sudo PRIV=sudo
UPDATE=\"guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u\" UPDATE=\"guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u\"
COPY_COMMAND=\"wl-copy\" COPY_COMMAND=\"wl-copy\"
PASTE_COMMAND=\"wl-paste\" PASTE_COMMAND=\"wl-paste\"
WIFI=wlp2s0 WIFI=wlp2s0
WM='sway' WM='sway'
#export WLR_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0 #export WLR_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0
elif [[ $HOSTNAME == Neon ]]; then elif [[ $HOSTNAME == Neon ]]; then
PRIV=sudo PRIV=sudo
UPDATE=\"guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u\" UPDATE=\"guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u\"
COPY_COMMAND=\"wl-copy\" COPY_COMMAND=\"wl-copy\"
PASTE_COMMAND=\"wl-paste\" PASTE_COMMAND=\"wl-paste\"
WIFI=wlp2s0 WIFI=wlp2s0
WM='sway' WM='sway'
export WLR_NO_HARDWARE_CURSORS=1 export WLR_NO_HARDWARE_CURSORS=1
else else
PRIV=sudo PRIV=sudo
UPDATE=\"$PRIV sh -c 'apt update && apt upgrade && apt autoremove'\" UPDATE=\"$PRIV sh -c 'apt update && apt upgrade && apt autoremove'\"
COPY_COMMAND=\"xclip -i -selection clipboard\" COPY_COMMAND=\"xclip -i -selection clipboard\"
PASTE_COMMAND=\"xclip -o -selection clipboard\" PASTE_COMMAND=\"xclip -o -selection clipboard\"
WIFI=wlp2s0 WIFI=wlp2s0
WM=\"bash\" WM=\"bash\"
fi")) fi"))
(define bash-profile (define bash-profile
@ -64,7 +64,7 @@ PERL_MM_OPT=\"INSTALL_BASE=/home/cobra/perl5\"; export PERL_MM_OPT;
. ~/.devspec . ~/.devspec
if [[ $(tty) == /dev/tty2 ]]; then if [[ $(tty) == /dev/tty2 ]]; then
exec $WM exec $WM
fi")) fi"))
(define prompt (define prompt
@ -85,195 +85,195 @@ _CYN=\"\\[\\033[36m\\]\"
_WHT=\"\\[\\033[37m\\]\" _WHT=\"\\[\\033[37m\\]\"
__debug_trap() { __debug_trap() {
# Set necessary pre-command variables (PROMPT_COMMAND is a # Set necessary pre-command variables (PROMPT_COMMAND is a
# command so its excluded here) # command so its excluded here)
if [[ \"$BASH_COMMAND\" != \"$PROMPT_COMMAND\" if [[ \"$BASH_COMMAND\" != \"$PROMPT_COMMAND\"
&& \"$LAST_BASH_COMMAND\" == \"$PROMPT_COMMAND\" ]]; then && \"$LAST_BASH_COMMAND\" == \"$PROMPT_COMMAND\" ]]; then
INC_TIME=1 INC_TIME=1
LAST_RT=\"$EPOCHREALTIME\" # This should be the last thing done in this function LAST_RT=\"$EPOCHREALTIME\" # This should be the last thing done in this function
fi fi
LAST_BASH_COMMAND=\"$BASH_COMMAND\" LAST_BASH_COMMAND=\"$BASH_COMMAND\"
} }
trap '__debug_trap' DEBUG trap '__debug_trap' DEBUG
__get_cmd_time() { __get_cmd_time() {
# Set hours minutes seconds and remove preceding zeros # Set hours minutes seconds and remove preceding zeros
local YEAR local YEAR
local DAYS local DAYS
local HOUR local HOUR
local MINS local MINS
local SECS local SECS
((YEAR=10#$(($(TZ=UTC printf '%(%Y)T' \"$CMD_TIME\")))-1970)) ((YEAR=10#$(($(TZ=UTC printf '%(%Y)T' \"$CMD_TIME\")))-1970))
((DAYS=10#$(TZ=UTC printf '%(%j)T' \"$CMD_TIME\"))) ((DAYS=10#$(TZ=UTC printf '%(%j)T' \"$CMD_TIME\")))
((HOUR=10#$(TZ=UTC printf '%(%H)T' \"$CMD_TIME\"))) ((HOUR=10#$(TZ=UTC printf '%(%H)T' \"$CMD_TIME\")))
((MINS=10#$(TZ=UTC printf '%(%M)T' \"$CMD_TIME\"))) ((MINS=10#$(TZ=UTC printf '%(%M)T' \"$CMD_TIME\")))
((SECS=10#$(TZ=UTC printf '%(%S)T' \"$CMD_TIME\"))) ((SECS=10#$(TZ=UTC printf '%(%S)T' \"$CMD_TIME\")))
# Choose whether or not to print hours minutes and seconds # Choose whether or not to print hours minutes and seconds
[[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' \"${YEAR}\" [[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' \"${YEAR}\"
[[ $CMD_TIME -ge 86400 ]] && printf '%sd ' \"${DAYS}\" [[ $CMD_TIME -ge 86400 ]] && printf '%sd ' \"${DAYS}\"
[[ $CMD_TIME -ge 3600 ]] && printf '%sh ' \"${HOUR}\" [[ $CMD_TIME -ge 3600 ]] && printf '%sh ' \"${HOUR}\"
[[ $CMD_TIME -ge 60 ]] && printf '%sm ' \"${MINS}\" [[ $CMD_TIME -ge 60 ]] && printf '%sm ' \"${MINS}\"
[[ $CMD_TIME -ge 1 ]] && printf '%ss ' \"${SECS}\" [[ $CMD_TIME -ge 1 ]] && printf '%ss ' \"${SECS}\"
# If you want to have a limit uncomment the next line and replace somenum with # If you want to have a limit uncomment the next line and replace somenum with
# the minimum microseconds # the minimum microseconds
# [[ $CMD_US -ge somenum ]] && # [[ $CMD_US -ge somenum ]] &&
printf '%sμs' \"${CMD_US:-0}\" printf '%sμs' \"${CMD_US:-0}\"
} }
__sig() { __sig() {
# Giant switch case for getting the name of the signal (`kill -l`) # Giant switch case for getting the name of the signal (`kill -l`)
local ITR=0 local ITR=0
local RET local RET
for RET in \"$@\"; do for RET in \"$@\"; do
if [[ $ITR != 0 ]]; then if [[ $ITR != 0 ]]; then
printf '%s|%s' \"$_WHT\" \"$_RED\" printf '%s|%s' \"$_WHT\" \"$_RED\"
fi fi
((ITR++)) ((ITR++))
case $RET in case $RET in
126): \"ACCES\" ;; 126): \"ACCES\" ;;
127): \"NOENT\" ;; 127): \"NOENT\" ;;
129): \"HUP\" ;; 129): \"HUP\" ;;
130): \"INT\" ;; 130): \"INT\" ;;
131): \"QUIT\" ;; 131): \"QUIT\" ;;
132): \"ILL\" ;; 132): \"ILL\" ;;
133): \"TRAP\" ;; 133): \"TRAP\" ;;
134): \"ABRT\" ;; 134): \"ABRT\" ;;
135): \"BUS\" ;; 135): \"BUS\" ;;
136): \"FPE\" ;; 136): \"FPE\" ;;
137): \"KILL\" ;; 137): \"KILL\" ;;
138): \"USR\"1 ;; 138): \"USR\"1 ;;
139): \"SEGV\" ;; 139): \"SEGV\" ;;
140): \"USR\"2 ;; 140): \"USR\"2 ;;
141): \"PIPE\" ;; 141): \"PIPE\" ;;
142): \"ALRM\" ;; 142): \"ALRM\" ;;
143): \"TERM\" ;; 143): \"TERM\" ;;
144): \"STKFLT\" ;; 144): \"STKFLT\" ;;
145): \"CHLD\" ;; 145): \"CHLD\" ;;
146): \"CONT\" ;; 146): \"CONT\" ;;
147): \"STOP\" ;; 147): \"STOP\" ;;
148): \"TSTP\" ;; 148): \"TSTP\" ;;
149): \"TTIN\" ;; 149): \"TTIN\" ;;
150): \"TTOU\" ;; 150): \"TTOU\" ;;
151): \"URG\" ;; 151): \"URG\" ;;
152): \"XCPU\" ;; 152): \"XCPU\" ;;
153): \"XFSZ\" ;; 153): \"XFSZ\" ;;
154): \"VTALRM\" ;; 154): \"VTALRM\" ;;
155): \"PROF\" ;; 155): \"PROF\" ;;
156): \"WINCH\" ;; 156): \"WINCH\" ;;
157): \"IO\" ;; 157): \"IO\" ;;
158): \"PWR\" ;; 158): \"PWR\" ;;
159): \"SYS\" ;; 159): \"SYS\" ;;
16[3-9]|1[7-8][0-9]|19[0-2]): \"RT$((RET-128))\" ;; # Savagery 16[3-9]|1[7-8][0-9]|19[0-2]): \"RT$((RET-128))\" ;; # Savagery
*): \"$RET\" ;; # Print exit code if not in list *): \"$RET\" ;; # Print exit code if not in list
esac esac
printf '%s' \"$_\" printf '%s' \"$_\"
done done
} }
__ssh() { __ssh() {
local CON=($SSH_CONNECTION) local CON=($SSH_CONNECTION)
local SRV_IP=\"${CON[2]}\" local SRV_IP=\"${CON[2]}\"
[[ -z \"$SRV_IP\" ]] && return [[ -z \"$SRV_IP\" ]] && return
local SRV_PORT=\"${CON[3]}\" local SRV_PORT=\"${CON[3]}\"
# 4 chars from startand 4 chars from end # 4 chars from startand 4 chars from end
local SRV_IP_CUT=\"${_CYN}${SRV_IP}\" local SRV_IP_CUT=\"${_CYN}${SRV_IP}\"
[[ ${#SRV_IP} -gt 8 ]] && local SRV_IP_CUT=\"${_CYN}${SRV_IP:0:4}${_WHT}*${_CYN}${SRV_IP: -4}\" [[ ${#SRV_IP} -gt 8 ]] && local SRV_IP_CUT=\"${_CYN}${SRV_IP:0:4}${_WHT}*${_CYN}${SRV_IP: -4}\"
printf '%s' \"${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}\" printf '%s' \"${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}\"
} }
__guix_env() { __guix_env() {
local re='[\\(]?\\(\"([^\"]*)\"' local re='[\\(]?\\(\"([^\"]*)\"'
if [[ \"$GUIX_ENVIRONMENT\" ]]; then if [[ \"$GUIX_ENVIRONMENT\" ]]; then
local PACKAGES=($(while read -r line; do local PACKAGES=($(while read -r line; do
[[ \"$line\" =~ $re ]] && printf '%s ' \"${BASH_REMATCH[1]}\" [[ \"$line\" =~ $re ]] && printf '%s ' \"${BASH_REMATCH[1]}\"
done < $GUIX_ENVIRONMENT/manifest)) done < $GUIX_ENVIRONMENT/manifest))
if [[ ${#PACKAGES[@]} -eq 2 ]]; then if [[ ${#PACKAGES[@]} -eq 2 ]]; then
printf \"${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkg${_BLD}${_BLU}] \" \"${PACKAGES[0]}\" \"$((${#PACKAGES[@]}-1))\" printf \"${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkg${_BLD}${_BLU}] \" \"${PACKAGES[0]}\" \"$((${#PACKAGES[@]}-1))\"
elif [[ ${#PACKAGES[@]} -gt 2 ]]; then elif [[ ${#PACKAGES[@]} -gt 2 ]]; then
printf \"${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkgs${_BLD}${_BLU}] \" \"${PACKAGES[0]}\" \"$((${#PACKAGES[@]}-1))\" printf \"${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkgs${_BLD}${_BLU}] \" \"${PACKAGES[0]}\" \"$((${#PACKAGES[@]}-1))\"
else else
printf \"${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s${_BLD}${_BLU}] \" \"${PACKAGES[@]}\" printf \"${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s${_BLD}${_BLU}] \" \"${PACKAGES[@]}\"
fi fi
fi fi
} }
__prompt() { __prompt() {
# Get exit code (must be first) # Get exit code (must be first)
local PLC=(\"${PIPESTATUS[@]}\") local PLC=(\"${PIPESTATUS[@]}\")
# Reset time when prompt was first displayed after command # Reset time when prompt was first displayed after command
# this contributes to the ~40 microsecond difference in $CMD_US and the actual time it took # this contributes to the ~40 microsecond difference in $CMD_US and the actual time it took
if [[ \"$INC_TIME\" != 0 ]]; then if [[ \"$INC_TIME\" != 0 ]]; then
PROMPT_RT=\"$EPOCHREALTIME\" PROMPT_RT=\"$EPOCHREALTIME\"
INC_TIME=0 INC_TIME=0
fi fi
# *_RT may not be set # *_RT may not be set
LAST_RT=\"${LAST_RT:-$EPOCHREALTIME}\" LAST_RT=\"${LAST_RT:-$EPOCHREALTIME}\"
PROMPT_RT=\"${PROMPT_RT:-$EPOCHREALTIME}\" PROMPT_RT=\"${PROMPT_RT:-$EPOCHREALTIME}\"
# Get relative times # Get relative times
# Remove decimal point, simulating multiplying by 1 million # Remove decimal point, simulating multiplying by 1 million
PROMPT_RT1M=\"${PROMPT_RT/.}\" PROMPT_RT1M=\"${PROMPT_RT/.}\"
PROMPT_RT1M=\"${PROMPT_RT1M/,}\" PROMPT_RT1M=\"${PROMPT_RT1M/,}\"
LAST_RT1M=\"${LAST_RT/.}\" LAST_RT1M=\"${LAST_RT/.}\"
LAST_RT1M=\"${LAST_RT1M/,}\" LAST_RT1M=\"${LAST_RT1M/,}\"
((CMD_US=PROMPT_RT1M-LAST_RT1M)) ((CMD_US=PROMPT_RT1M-LAST_RT1M))
CMD_TIME=0 CMD_TIME=0
# Divide by 1 million to get a more accurate difference # Divide by 1 million to get a more accurate difference
((CMD_TIME=CMD_US/1000000)) ((CMD_TIME=CMD_US/1000000))
[[ ${#CMD_US} -lt 6 ]] || CMD_US=\"${CMD_US: -6}\" [[ ${#CMD_US} -lt 6 ]] || CMD_US=\"${CMD_US: -6}\"
((CMD_US=10#$CMD_US)) ((CMD_US=10#$CMD_US))
# Set prompt sections # Set prompt sections
local SIG local SIG
local COL local COL
local UHD local UHD
local TIME local TIME
local IND local IND
local GUIX local GUIX
# Text # Text
# ssh detection and indicator # ssh detection and indicator
[[ \"$SSH_CONNECTION\" ]] && local SSH=\"$(__ssh) \" [[ \"$SSH_CONNECTION\" ]] && local SSH=\"$(__ssh) \"
# [INT], [4], etc. # [INT], [4], etc.
local RET local RET
for RET in \"${PLC[@]}\"; do for RET in \"${PLC[@]}\"; do
if [[ $RET -gt 0 ]]; then if [[ $RET -gt 0 ]]; then
SIG=\"$(printf '%s[%s%s%s] ' \"$_BLU\" \"$_RED\" \"$(__sig \"${PLC[@]}\")\" \"$_BLU\")\" SIG=\"$(printf '%s[%s%s%s] ' \"$_BLU\" \"$_RED\" \"$(__sig \"${PLC[@]}\")\" \"$_BLU\")\"
break break
fi fi
done done
# Guix shell environment # Guix shell environment
GUIX=\"$(__guix_env)\" GUIX=\"$(__guix_env)\"
# [user@homeserver:~] # [user@homeserver:~]
COL=\"$([[ $UID == 0 ]] && printf '%s' \"$_RED\" || printf '%s' \"$_YLW\")\" COL=\"$([[ $UID == 0 ]] && printf '%s' \"$_RED\" || printf '%s' \"$_YLW\")\"
UHD=\"${_BLD}${_BLU}[${COL}\\u${_PRP}@${_CYN}\\h${_PRP}:${_GRN}\\w${_BLU}]\" UHD=\"${_BLD}${_BLU}[${COL}\\u${_PRP}@${_CYN}\\h${_PRP}:${_GRN}\\w${_BLU}]\"
# 2y 351d 12m 43s 382969μs # 2y 351d 12m 43s 382969μs
TIME=\"${_YLW}$(__get_cmd_time)\" TIME=\"${_YLW}$(__get_cmd_time)\"
# Random colored $ or # # Random colored $ or #
_RAND256=\"\\[\\033[38;2;$((RANDOM%256));$((RANDOM%256));$((RANDOM%256))m\\]\" _RAND256=\"\\[\\033[38;2;$((RANDOM%256));$((RANDOM%256));$((RANDOM%256))m\\]\"
IND=\"${_RAND256}\\\\$\" IND=\"${_RAND256}\\\\$\"
# Set the prompt # Set the prompt
PS1=\"${_NON}${SSH}${GUIX}${SIG}${UHD} ${TIME} ${IND} ${_NON}\" PS1=\"${_NON}${SSH}${GUIX}${SIG}${UHD} ${TIME} ${IND} ${_NON}\"
} }
PROMPT_COMMAND=__prompt")) PROMPT_COMMAND=__prompt"))
(define bashrc (define bashrc
@ -298,7 +298,7 @@ export GPG_TTY=$(tty)
export MANPATH=/run/current-system/profile/share/man:/home/cobra/.guix-profile/share/man:/run/current-system/profile/share/man:/home/cobra/.guix-home/profile/share/man export MANPATH=/run/current-system/profile/share/man:/home/cobra/.guix-profile/share/man:/run/current-system/profile/share/man:/home/cobra/.guix-home/profile/share/man
clear() { clear() {
printf '\\033c' # faster than ncurses clear by a lot printf '\\033c' # faster than ncurses clear by a lot
} }
# Other aliases # Other aliases
@ -319,7 +319,7 @@ alias dico=\"dico -d en-wiktionary\"
# Random string (passwords) # Random string (passwords)
randstr() { randstr() {
tr -cd '[:graph:]' </dev/urandom | head -c ${1:-256} tr -cd '[:graph:]' </dev/urandom | head -c ${1:-256}
} }
# Get CPU usage # Get CPU usage
@ -332,227 +332,227 @@ update() { $PRIV sh -c \"$UPDATE\"; }
# Im too lazy to type # Im too lazy to type
copy() { copy() {
printf \"%s\" \"$(</dev/stdin)\" > >($COPY_COMMAND) printf \"%s\" \"$(</dev/stdin)\" > >($COPY_COMMAND)
} }
# URL-encode stdin # URL-encode stdin
urlencode() { urlencode() {
LC_COLLATE_OLD=$LC_COLLATE LC_COLLATE_OLD=$LC_COLLATE
LC_COLLATE=C LC_COLLATE=C
local TEXT=\"$(</dev/stdin)\" local TEXT=\"$(</dev/stdin)\"
local LENGTH=\"${#TEXT}\" local LENGTH=\"${#TEXT}\"
for (( i = 0; i < LENGTH; i++ )); do for (( i = 0; i < LENGTH; i++ )); do
local c=\"${TEXT:$i:1}\" local c=\"${TEXT:$i:1}\"
case $c in case $c in
[a-zA-Z0-9.~_-]) printf '%s' \"$c\" ;; [a-zA-Z0-9.~_-]) printf '%s' \"$c\" ;;
*) printf '%%%02X' \"'$c\" ;; *) printf '%%%02X' \"'$c\" ;;
esac esac
done done
LC_COLLATE=$LC_COLLATE_OLD LC_COLLATE=$LC_COLLATE_OLD
} }
diffhome() { find . -type f -regex '\\./\\.[^g].*' -exec diff -q ~/{} {} 2> /dev/null \\;; } diffhome() { find . -type f -regex '\\./\\.[^g].*' -exec diff -q ~/{} {} 2> /dev/null \\;; }
fixdh() { fixdh() {
diffhome | while read -r _ SRC _ DEST _; do diffhome | while read -r _ SRC _ DEST _; do
cp $SRC $DEST; cp $SRC $DEST;
done; done;
} }
strlen() { strlen() {
N=$(wc -c <<< \"$*\") N=$(wc -c <<< \"$*\")
((N--)) ((N--))
printf '%u\\n' \"$N\" printf '%u\\n' \"$N\"
} }
uppweb() { uppweb() {
ssh vern.cc 'cd ~/public_html; git pull' ssh vern.cc 'cd ~/public_html; git pull'
} }
caption() { caption() {
[ -z \"$3\" ] && { [ -z \"$3\" ] && {
echo \"Usage: caption [input] [output] [text...]\" echo \"Usage: caption [input] [output] [text...]\"
return 1 return 1
} }
local FILE=\"$1\" local FILE=\"$1\"
local OUT=\"$2\" local OUT=\"$2\"
shift 2 shift 2
local TEXT=\"$*\" local TEXT=\"$*\"
local WIDTH=\"$(identify -format \"%[w]\\n\" \"$FILE\" | head -n1)\" local WIDTH=\"$(identify -format \"%[w]\\n\" \"$FILE\" | head -n1)\"
local HEIGHT=\"$(identify -format \"%[h]\\n\" \"$FILE\" | head -n1)\" local HEIGHT=\"$(identify -format \"%[h]\\n\" \"$FILE\" | head -n1)\"
local FONT_SIZE=\"$(((HEIGHT+WIDTH)/20))\" local FONT_SIZE=\"$(((HEIGHT+WIDTH)/20))\"
convert -gravity north \\( -size \"${WIDTH}x\" -pointsize \"$FONT_SIZE\" -font 'Liberation-Sans-Bold' caption:\"$TEXT\" -gravity Center -extent \"${WIDTH}x\" \\) \"$FILE\" -append \"$OUT\" convert -gravity north \\( -size \"${WIDTH}x\" -pointsize \"$FONT_SIZE\" -font 'Liberation-Sans-Bold' caption:\"$TEXT\" -gravity Center -extent \"${WIDTH}x\" \\) \"$FILE\" -append \"$OUT\"
} }
captionvid() { captionvid() {
[ -z \"$3\" ] && { [ -z \"$3\" ] && {
echo \"Usage: captionvid [input] [output] [text...]\" echo \"Usage: captionvid [input] [output] [text...]\"
return 1 return 1
} }
rm /tmp/caption.*.png rm /tmp/caption.*.png
FPS=\"$(ffmpeg -i \"$1\" 2>&1 |grep fps | sed 's/.* \\([0-9]\\+\\) fps.*/\\1/')\" FPS=\"$(ffmpeg -i \"$1\" 2>&1 |grep fps | sed 's/.* \\([0-9]\\+\\) fps.*/\\1/')\"
IN=\"$1\" IN=\"$1\"
OUT=\"$2\" OUT=\"$2\"
shift 2 shift 2
ffmpeg -i \"$IN\" \"/tmp/caption.%02d.png\" ffmpeg -i \"$IN\" \"/tmp/caption.%02d.png\"
for i in /tmp/caption.*; do for i in /tmp/caption.*; do
caption \"$i\" \"$i-new.png\" \"$*\" caption \"$i\" \"$i-new.png\" \"$*\"
done done
ffmpeg -framerate $FPS -i \"/tmp/caption.%02d.png-new.png\" \"$OUT\" ffmpeg -framerate $FPS -i \"/tmp/caption.%02d.png-new.png\" \"$OUT\"
rm /tmp/caption.*.png rm /tmp/caption.*.png
} }
topbottom() { topbottom() {
[ -z \"$3\" ] && { [ -z \"$3\" ] && {
echo \"Usage: caption [input] [output] [text...]\" echo \"Usage: caption [input] [output] [text...]\"
return 1 return 1
} }
local FILE=\"$1\" local FILE=\"$1\"
local OUT=\"$2\" local OUT=\"$2\"
shift 2 shift 2
local WIDTH=\"$(identify -format \"%[w]\\n\" \"$FILE\" | head -n1)\" local WIDTH=\"$(identify -format \"%[w]\\n\" \"$FILE\" | head -n1)\"
local HEIGHT=\"$(identify -format \"%[h]\\n\" \"$FILE\" | head -n1)\" local HEIGHT=\"$(identify -format \"%[h]\\n\" \"$FILE\" | head -n1)\"
local FONT_SIZE=\"$(((HEIGHT+WIDTH)/20))\" local FONT_SIZE=\"$(((HEIGHT+WIDTH)/20))\"
convert -size \"${WIDTH}x\" -stroke black -strokewidth 3 -fill white -pointsize \"$FONT_SIZE\" -font 'Liberation-Sans-Bold' -gravity Center -extent \"${WIDTH}x\" -gravity north \\( -annotate +0+0 \"$1\" \\) -gravity south \\( -annotate +0+0 \"$2\" \\) \"$FILE\" -append \"$OUT\" convert -size \"${WIDTH}x\" -stroke black -strokewidth 3 -fill white -pointsize \"$FONT_SIZE\" -font 'Liberation-Sans-Bold' -gravity Center -extent \"${WIDTH}x\" -gravity north \\( -annotate +0+0 \"$1\" \\) -gravity south \\( -annotate +0+0 \"$2\" \\) \"$FILE\" -append \"$OUT\"
} }
topbottomvid() { topbottomvid() {
[ -z \"$3\" ] && { [ -z \"$3\" ] && {
echo \"Usage: captionvid [input] [output] [text...]\" echo \"Usage: captionvid [input] [output] [text...]\"
return 1 return 1
} }
rm /tmp/caption.*.png rm /tmp/caption.*.png
FPS=\"$(ffmpeg -i \"$1\" 2>&1 |grep fps | sed 's/.* \\([0-9]\\+\\) fps.*/\\1/')\" FPS=\"$(ffmpeg -i \"$1\" 2>&1 |grep fps | sed 's/.* \\([0-9]\\+\\) fps.*/\\1/')\"
IN=\"$1\" IN=\"$1\"
OUT=\"$2\" OUT=\"$2\"
shift 2 shift 2
ffmpeg -i \"$IN\" \"/tmp/caption.%02d.png\" ffmpeg -i \"$IN\" \"/tmp/caption.%02d.png\"
for i in /tmp/caption.*; do for i in /tmp/caption.*; do
topbottom \"$i\" \"$i-new.png\" \"$1\" \"$2\" topbottom \"$i\" \"$i-new.png\" \"$1\" \"$2\"
done done
ffmpeg -framerate $FPS -i \"/tmp/caption.%02d.png-new.png\" \"$OUT\" ffmpeg -framerate $FPS -i \"/tmp/caption.%02d.png-new.png\" \"$OUT\"
rm /tmp/caption.*.png rm /tmp/caption.*.png
} }
subcipher() { subcipher() {
local COLOR PERM L1 line grep word local COLOR PERM L1 line grep word
if [ $# -lt 3 ]; then if [ $# -lt 3 ]; then
if [ $# -lt 2 ] || [[ \"$1\" != \"0\" && \"$1\" != \"1\" ]]; then if [ $# -lt 2 ] || [[ \"$1\" != \"0\" && \"$1\" != \"1\" ]]; then
printf \"Usage: [0|1] subcipher file [string...]\\n\" printf \"Usage: [0|1] subcipher file [string...]\\n\"
return 1 return 1
fi fi
fi fi
COLOR=\"$1\" COLOR=\"$1\"
shift shift
PERM=\"$1\" PERM=\"$1\"
shift shift
[ -z \"$*\" ] && set -- \"$(</dev/stdin)\" [ -z \"$*\" ] && set -- \"$(</dev/stdin)\"
L1=\"$(head -1 \"$PERM\")\" L1=\"$(head -1 \"$PERM\")\"
while read -r line; do while read -r line; do
tr \"${L1^^}${L1}\" \"${line^^}${line}\" <<< \"$*\" tr \"${L1^^}${L1}\" \"${line^^}${line}\" <<< \"$*\"
done < \"$PERM\" | \ done < \"$PERM\" | \
while read -r line; do while read -r line; do
for word in $line; do for word in $line; do
[ $COLOR -eq 1 ] && grep=\"$(grep --color=always -xF \"$word\" /etc/dictionaries-common/words)\" [ $COLOR -eq 1 ] && grep=\"$(grep --color=always -xF \"$word\" /etc/dictionaries-common/words)\"
printf %s \"${grep:-$word} \" printf %s \"${grep:-$word} \"
done done
printf '\\n' printf '\\n'
done done
} }
playcd() { playcd() {
mpv --start=00:00:00.0000000 av://libcdio:/dev/cdrom --cache=yes mpv --start=00:00:00.0000000 av://libcdio:/dev/cdrom --cache=yes
} }
playdvd() { playdvd() {
mpv --start=00:00:00.0000000 dvd:///dev/sr0 --cache=yes mpv --start=00:00:00.0000000 dvd:///dev/sr0 --cache=yes
} }
gpginfo() { gpginfo() {
gpg --with-colons --import-options show-only --import gpg --with-colons --import-options show-only --import
} }
lc() { lc() {
fc -nl $HISTCMD | sed 's/^\\s*//' fc -nl $HISTCMD | sed 's/^\\s*//'
} }
baseto() { baseto() {
if [ $# -ge 3 ]; then if [ $# -ge 3 ]; then
local i=\"$1\" local i=\"$1\"
local o=\"$2\" local o=\"$2\"
shift 2 shift 2
bc <<< \"obase=$o;$(($i#$*))\" bc <<< \"obase=$o;$(($i#$*))\"
else else
local line i o n local line i o n
while read -r line; do while read -r line; do
read -r i o n <<< \"$line\" read -r i o n <<< \"$line\"
bc <<< \"obase=$o;$(($i#$n))\" bc <<< \"obase=$o;$(($i#$n))\"
done done
fi fi
} }
rebash() { . ~/.bashrc; } rebash() { . ~/.bashrc; }
bashrc() { \"$EDITOR\" ~/.bashrc && rebash; } bashrc() { \"$EDITOR\" ~/.bashrc && rebash; }
uplot() { uplot() {
ssh vern \"${1:-/opt/gnuplot/users/gnuplot.sh}; cat /opt/gnuplot/users/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh vern \"${1:-/opt/gnuplot/users/gnuplot.sh}; cat /opt/gnuplot/users/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
mnplot() { mnplot() {
ssh mythos \"${1:-/opt/gnuplot/gnuplot.sh}; cat /opt/gnuplot/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh mythos \"${1:-/opt/gnuplot/gnuplot.sh}; cat /opt/gnuplot/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
vnplot() { vnplot() {
ssh vern \"${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh vern \"${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
vpplot() { vpplot() {
ssh vern \"${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh vern \"${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
inplot() { inplot() {
ssh iceberg \"${1:-~/gnuplot/gnuplot.sh}; cat ~/gnuplot/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh iceberg \"${1:-~/gnuplot/gnuplot.sh}; cat ~/gnuplot/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
cnplot() { cnplot() {
ssh crescent \"${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh crescent \"${1:-/opt/gnuplot/net/gnuplot.sh}; cat /opt/gnuplot/net/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
cpplot() { cpplot() {
ssh crescent \"${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg ssh crescent \"${1:-/opt/gnuplot/power/gnuplot.sh}; cat /opt/gnuplot/power/${1:-$(date -u -I)}.svg\" > ${1:-$(date -u -I)}.svg
} }
reconf() { reconf() {
$PRIV su - -c \"guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm\" $PRIV su - -c \"guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm\"
} }
hreconf() { hreconf() {
guix home reconfigure $HOME/.config/guix/home.scm guix home reconfigure $HOME/.config/guix/home.scm
} }
geng() { geng() {
< \"$1\" sed 's/\\s*;.*//' | grep -ve '^$' -e '^T' | awk '{print \"N\"NR\" \"$0}' > \"$2\" < \"$1\" sed 's/\\s*;.*//' | grep -ve '^$' -e '^T' | awk '{print \"N\"NR\" \"$0}' > \"$2\"
} }
mkmshex() { mkmshex() {
FILE=\"${1%.*}\" FILE=\"${1%.*}\"
microscheme \"$1\" microscheme \"$1\"
avr-gcc -B /run/current-system/profile/avr/lib/avr5 -mmcu=\"$2\" -g -Os \"$FILE\".s -o \"$FILE\".elf avr-gcc -B /run/current-system/profile/avr/lib/avr5 -mmcu=\"$2\" -g -Os \"$FILE\".s -o \"$FILE\".elf
avr-objcopy -Oihex \"$FILE\".o \"$FILE\".hex avr-objcopy -Oihex \"$FILE\".o \"$FILE\".hex
} }
uploadhex() { uploadhex() {
avrdude -C/run/current-system/profile/etc/avrdude.conf -v -p\"$2\" -carduino -P${3:-/dev/ttyS0} -U\"flash:w:$1:i\" avrdude -C/run/current-system/profile/etc/avrdude.conf -v -p\"$2\" -carduino -P${3:-/dev/ttyS0} -U\"flash:w:$1:i\"
} }
gshpkg() { gshpkg() {
local re='[\\(]?\\(\"([^\"]*)\"' local re='[\\(]?\\(\"([^\"]*)\"'
if [[ \"$GUIX_ENVIRONMENT\" ]]; then if [[ \"$GUIX_ENVIRONMENT\" ]]; then
local PACKAGES=($(while read -r line; do local PACKAGES=($(while read -r line; do
[[ \"$line\" =~ $re ]] && printf '%s ' \"${BASH_REMATCH[1]}\" [[ \"$line\" =~ $re ]] && printf '%s ' \"${BASH_REMATCH[1]}\"
done < $GUIX_ENVIRONMENT/manifest)) done < $GUIX_ENVIRONMENT/manifest))
echo ${PACKAGES[@]} echo ${PACKAGES[@]}
fi fi
}")) }"))

View File

@ -10,10 +10,10 @@
(gnu services mcron) (gnu services mcron)
(guix gexp) (guix gexp)
;; Deranged Guix Home Configuration Usage(TM) ;; Deranged Guix Home Usage(TM)
(cobra homedir) (cobra homedir)
(cobra bin) (cobra config)
(cobra config)) (cobra bin))
(define webfetch-job (define webfetch-job
#~(job "*/1 * * * *" #~(job "*/1 * * * *"

View File

@ -1,33 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [[ $HOSTNAME == pp ]]; then if [[ $HOSTNAME == pp ]]; then
PRIV=doas PRIV=doas
UPDATE="$PRIV sh -c 'apk update && apk upgrade -aiv && apk fix'" UPDATE="$PRIV sh -c 'apk update && apk upgrade -aiv && apk fix'"
COPY_COMMAND="wl-copy" COPY_COMMAND="wl-copy"
PASTE_COMMAND="wl-paste" PASTE_COMMAND="wl-paste"
WIFI=wlan0 WIFI=wlan0
WM="bash" WM="bash"
elif [[ $HOSTNAME == Xenon ]]; then elif [[ $HOSTNAME == Oganesson ]]; then
PRIV=sudo PRIV=sudo
UPDATE="guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u" UPDATE="guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u"
COPY_COMMAND="wl-copy" COPY_COMMAND="wl-copy"
PASTE_COMMAND="wl-paste" PASTE_COMMAND="wl-paste"
WIFI=wlp2s0 WIFI=wlp2s0
WM='sway' WM='sway'
#export WLR_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0 #export WLR_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0
elif [[ $HOSTNAME == Neon ]]; then elif [[ $HOSTNAME == Neon ]]; then
PRIV=sudo PRIV=sudo
UPDATE="guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u" UPDATE="guix pull --branch=master && guix system reconfigure /etc/guix-config/${HOSTNAME,,}.scm && guix package -u"
COPY_COMMAND="wl-copy" COPY_COMMAND="wl-copy"
PASTE_COMMAND="wl-paste" PASTE_COMMAND="wl-paste"
WIFI=wlp2s0 WIFI=wlp2s0
WM='sway' WM='sway'
export WLR_NO_HARDWARE_CURSORS=1 export WLR_NO_HARDWARE_CURSORS=1
else else
PRIV=sudo PRIV=sudo
UPDATE="$PRIV sh -c 'apt update && apt upgrade && apt autoremove'" UPDATE="$PRIV sh -c 'apt update && apt upgrade && apt autoremove'"
COPY_COMMAND="xclip -i -selection clipboard" COPY_COMMAND="xclip -i -selection clipboard"
PASTE_COMMAND="xclip -o -selection clipboard" PASTE_COMMAND="xclip -o -selection clipboard"
WIFI=wlp2s0 WIFI=wlp2s0
WM="bash" WM="bash"
fi fi

View File

@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo mem > /sys/power/state echo mem > /sys/power/state

View File

@ -5,11 +5,11 @@ cpu() {
} }
ram() { ram() {
free -h | sed '2!d' | (read _ _ used _; echo $used) free -h | sed '2!d' | (read _ _ used _; echo $used)
} }
bat() { bat() {
acpi -b | sed 's/Battery /BAT/' acpi -b | sed 's/Battery /BAT/'
} }
echo "$(cpu)% $(ram) $(bat)" echo "$(cpu)% $(ram) $(bat)"

View File

@ -1,2 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
echo $1 > /proc/acpi/ibm/beep echo $1 > /proc/acpi/ibm/beep

View File

@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
while sleep 1; do while sleep 1; do
## Battery beep ## Battery beep
if ls /sys/class/power_supply/BAT* &>/dev/null; then if ls /sys/class/power_supply/BAT* &>/dev/null; then
BAT0=$(</sys/class/power_supply/BAT0/capacity) BAT0=$(</sys/class/power_supply/BAT0/capacity)
if [[ $BAT0 -le 5 && -z "$BEEPED" && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then if [[ $BAT0 -le 5 && -z "$BEEPED" && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then
sudo ~/.local/bin/beep 9 sudo ~/.local/bin/beep 9
BEEPED=1 BEEPED=1
elif [[ $BAT0 -le 2 && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then elif [[ $BAT0 -le 2 && $(</sys/class/power_supply/BAT0/status) == Discharging ]]; then
sudo ~/.local/bin/beep 9 sudo ~/.local/bin/beep 9
BEEPED=0 BEEPED=0
fi fi
fi fi
done done

View File

@ -5,4 +5,4 @@ if [[ -S "/tmp/mpvfsfsock" ]]; then
else else
mpv --input-ipc-server=/tmp/mpvfsfsock ~/.local/share/fss.ogg mpv --input-ipc-server=/tmp/mpvfsfsock ~/.local/share/fss.ogg
trap "rm -rf /tmp/mpvfsfsock" EXIT trap "rm -rf /tmp/mpvfsfsock" EXIT
fi fi

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if ! ps aux | grep -v grep | grep swaylock; then if ! ps aux | grep -v grep | grep swaylock; then
# if [[ $(playerctl status) != "Playing" ]]; then # if [[ $(playerctl status) != "Playing" ]]; then
# swayidle -w timeout 600 'sudo ~/.local/bin/__suspend' & # swayidle -w timeout 600 'sudo ~/.local/bin/__suspend' &
# SUSPEND=$! # SUSPEND=$!
# fi # fi
swayidle -w timeout 15 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' & swayidle -w timeout 15 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' &
SCREENOFF=$! SCREENOFF=$!
swaylock swaylock
kill $SUSPEND $SCREENOFF kill $SUSPEND $SCREENOFF
fi fi

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
case "$(printf "logout\nreboot\nshutdown\nsleep\n" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )" in case "$(printf "logout\nreboot\nshutdown\nsleep\n" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )" in
'logout') swaymsg exit;; 'logout') swaymsg exit;;
'sleep') ~/.local/bin/suspend ;; 'sleep') ~/.local/bin/suspend ;;
'reboot') sudo reboot ;; 'reboot') sudo reboot ;;
'shutdown') sudo poweroff ;; 'shutdown') sudo poweroff ;;
*) exit 1 ;; *) exit 1 ;;
esac esac

View File

@ -2,41 +2,41 @@
if [ ! -d $HOME/Pictures/Screenshots ] if [ ! -d $HOME/Pictures/Screenshots ]
then then
mkdir -p $HOME/Pictures/Screenshots mkdir -p $HOME/Pictures/Screenshots
fi fi
fullscreen() { fullscreen() {
filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Fullscreen).png filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Fullscreen).png
grim $filename grim $filename
cat $filename | wl-copy && notify-send -i $filename "Fullscreen Screenshot taken" cat $filename | wl-copy && notify-send -i $filename "Fullscreen Screenshot taken"
} }
selecting() { selecting() {
filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Selected).png filename=$HOME/Pictures/Screenshots/$(date +%Y%m%d_%H:%M:%S_Selected).png
grim -g "$(slurp -b e3eaf699)" $filename && notify-send -i $filename "Selective Screenshot taken" grim -g "$(slurp -b e3eaf699)" $filename && notify-send -i $filename "Selective Screenshot taken"
cat $filename | wl-copy cat $filename | wl-copy
} }
wofirun() { wofirun() {
case "$(printf "fullscreen\nselect\n" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )" in case "$(printf "fullscreen\nselect\n" | wofi --dmenu -i -H 500 -W 250 -x 0 -y 0 )" in
'fullscreen')fullscreen;; 'fullscreen')fullscreen;;
'select')selecting;; 'select')selecting;;
esac esac
} }
helpscreen() { helpscreen() {
echo "Usage: screenshot [-f] [-s] [-w] [-h] " echo "Usage: screenshot [-f] [-s] [-w] [-h] "
echo "Options:" echo "Options:"
echo "-f : Fullscreen screenshot" echo "-f : Fullscreen screenshot"
echo "-s : Select a region for the screenshot" echo "-s : Select a region for the screenshot"
echo "-w : Shows a wofi prompt for screenshot" echo "-w : Shows a wofi prompt for screenshot"
echo "-h : Shows this fucking help menu" echo "-h : Shows this fucking help menu"
echo "If no flags are selected then -f is chosen" echo "If no flags are selected then -f is chosen"
} }
case $1 in case $1 in
-f)fullscreen;; -f)fullscreen;;
-s)selecting;; -s)selecting;;
-h)helpscreen;; -h)helpscreen;;
-w)wofirun;; -w)wofirun;;
*)fullscreen;; *)fullscreen;;
esac esac

View File

@ -6,4 +6,4 @@ rm -rf /run/user/$UID/pulse
pipewire & pipewire &
pipewire-pulse & pipewire-pulse &
wireplumber & wireplumber &

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
sudo ~/.local/bin/__suspend sudo ~/.local/bin/__suspend
while grep -v '\[' /sys/power/state; do while grep -v '\[' /sys/power/state; do
swaylock swaylock
break break
done done

View File

@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cd ~/.local/share/torbrowser/tor-browser/ cd ~/.local/share/torbrowser/tor-browser/
guix shell --check --pure --expression='(list (@@ (gnu packages gcc) gcc-11) "lib")' coreutils bash grep sed gcc-toolchain patchelf gtk+ dbus-glib libxt libevent openssl file alsa-lib << EOF guix shell --check --pure --expression='(list (@@ (gnu packages gcc) gcc-11) "lib")' coreutils bash grep sed gcc-toolchain patchelf gtk+ dbus-glib libxt libevent openssl file alsa-lib << "EOF" >/gnu/store/fivbm252q6y700l89dvqm4mgdgpf0dpc-bin-torbrowser1
set -x set -x
cd Browser cd Browser
patchelf --set-interpreter \$LIBRARY_PATH/ld-linux-x86-64.so.2 firefox.real patchelf --set-interpreter \$LIBRARY_PATH/ld-linux-x86-64.so.2 firefox.real
patchelf --set-interpreter \$LIBRARY_PATH/ld-linux-x86-64.so.2 TorBrowser/Tor/tor patchelf --set-interpreter \$LIBRARY_PATH/ld-linux-x86-64.so.2 TorBrowser/Tor/tor
LD_LIBRARY_PATH=\$LIBRARY_PATH ./start-tor-browser -v LD_LIBRARY_PATH=\$LIBRARY_PATH ./start-tor-browser -v
EOF EOT

302
.prompt
View File

@ -14,193 +14,193 @@ _CYN="\[\033[36m\]"
_WHT="\[\033[37m\]" _WHT="\[\033[37m\]"
__debug_trap() { __debug_trap() {
# Set necessary pre-command variables (PROMPT_COMMAND is a # Set necessary pre-command variables (PROMPT_COMMAND is a
# command so its excluded here) # command so its excluded here)
if [[ "$BASH_COMMAND" != "$PROMPT_COMMAND" if [[ "$BASH_COMMAND" != "$PROMPT_COMMAND"
&& "$LAST_BASH_COMMAND" == "$PROMPT_COMMAND" ]]; then && "$LAST_BASH_COMMAND" == "$PROMPT_COMMAND" ]]; then
INC_TIME=1 INC_TIME=1
LAST_RT="$EPOCHREALTIME" # This should be the last thing done in this function LAST_RT="$EPOCHREALTIME" # This should be the last thing done in this function
fi fi
LAST_BASH_COMMAND="$BASH_COMMAND" LAST_BASH_COMMAND="$BASH_COMMAND"
} }
trap '__debug_trap' DEBUG trap '__debug_trap' DEBUG
__get_cmd_time() { __get_cmd_time() {
# Set hours minutes seconds and remove preceding zeros # Set hours minutes seconds and remove preceding zeros
local YEAR local YEAR
local DAYS local DAYS
local HOUR local HOUR
local MINS local MINS
local SECS local SECS
((YEAR=10#$(($(TZ=UTC printf '%(%Y)T' "$CMD_TIME")))-1970)) ((YEAR=10#$(($(TZ=UTC printf '%(%Y)T' "$CMD_TIME")))-1970))
((DAYS=10#$(TZ=UTC printf '%(%j)T' "$CMD_TIME"))) ((DAYS=10#$(TZ=UTC printf '%(%j)T' "$CMD_TIME")))
((HOUR=10#$(TZ=UTC printf '%(%H)T' "$CMD_TIME"))) ((HOUR=10#$(TZ=UTC printf '%(%H)T' "$CMD_TIME")))
((MINS=10#$(TZ=UTC printf '%(%M)T' "$CMD_TIME"))) ((MINS=10#$(TZ=UTC printf '%(%M)T' "$CMD_TIME")))
((SECS=10#$(TZ=UTC printf '%(%S)T' "$CMD_TIME"))) ((SECS=10#$(TZ=UTC printf '%(%S)T' "$CMD_TIME")))
# Choose whether or not to print hours minutes and seconds # Choose whether or not to print hours minutes and seconds
[[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' "${YEAR}" [[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' "${YEAR}"
[[ $CMD_TIME -ge 86400 ]] && printf '%sd ' "${DAYS}" [[ $CMD_TIME -ge 86400 ]] && printf '%sd ' "${DAYS}"
[[ $CMD_TIME -ge 3600 ]] && printf '%sh ' "${HOUR}" [[ $CMD_TIME -ge 3600 ]] && printf '%sh ' "${HOUR}"
[[ $CMD_TIME -ge 60 ]] && printf '%sm ' "${MINS}" [[ $CMD_TIME -ge 60 ]] && printf '%sm ' "${MINS}"
[[ $CMD_TIME -ge 1 ]] && printf '%ss ' "${SECS}" [[ $CMD_TIME -ge 1 ]] && printf '%ss ' "${SECS}"
# If you want to have a limit uncomment the next line and replace somenum with # If you want to have a limit uncomment the next line and replace somenum with
# the minimum microseconds # the minimum microseconds
# [[ $CMD_US -ge somenum ]] && # [[ $CMD_US -ge somenum ]] &&
printf '%sμs' "${CMD_US:-0}" printf '%sμs' "${CMD_US:-0}"
} }
__sig() { __sig() {
# Giant switch case for getting the name of the signal (`kill -l`) # Giant switch case for getting the name of the signal (`kill -l`)
local ITR=0 local ITR=0
local RET local RET
for RET in "$@"; do for RET in "$@"; do
if [[ $ITR != 0 ]]; then if [[ $ITR != 0 ]]; then
printf '%s|%s' "$_WHT" "$_RED" printf '%s|%s' "$_WHT" "$_RED"
fi fi
((ITR++)) ((ITR++))
case $RET in case $RET in
126): "ACCES" ;; 126): "ACCES" ;;
127): "NOENT" ;; 127): "NOENT" ;;
129): "HUP" ;; 129): "HUP" ;;
130): "INT" ;; 130): "INT" ;;
131): "QUIT" ;; 131): "QUIT" ;;
132): "ILL" ;; 132): "ILL" ;;
133): "TRAP" ;; 133): "TRAP" ;;
134): "ABRT" ;; 134): "ABRT" ;;
135): "BUS" ;; 135): "BUS" ;;
136): "FPE" ;; 136): "FPE" ;;
137): "KILL" ;; 137): "KILL" ;;
138): "USR"1 ;; 138): "USR"1 ;;
139): "SEGV" ;; 139): "SEGV" ;;
140): "USR"2 ;; 140): "USR"2 ;;
141): "PIPE" ;; 141): "PIPE" ;;
142): "ALRM" ;; 142): "ALRM" ;;
143): "TERM" ;; 143): "TERM" ;;
144): "STKFLT" ;; 144): "STKFLT" ;;
145): "CHLD" ;; 145): "CHLD" ;;
146): "CONT" ;; 146): "CONT" ;;
147): "STOP" ;; 147): "STOP" ;;
148): "TSTP" ;; 148): "TSTP" ;;
149): "TTIN" ;; 149): "TTIN" ;;
150): "TTOU" ;; 150): "TTOU" ;;
151): "URG" ;; 151): "URG" ;;
152): "XCPU" ;; 152): "XCPU" ;;
153): "XFSZ" ;; 153): "XFSZ" ;;
154): "VTALRM" ;; 154): "VTALRM" ;;
155): "PROF" ;; 155): "PROF" ;;
156): "WINCH" ;; 156): "WINCH" ;;
157): "IO" ;; 157): "IO" ;;
158): "PWR" ;; 158): "PWR" ;;
159): "SYS" ;; 159): "SYS" ;;
16[3-9]|1[7-8][0-9]|19[0-2]): "RT$((RET-128))" ;; # Savagery 16[3-9]|1[7-8][0-9]|19[0-2]): "RT$((RET-128))" ;; # Savagery
*): "$RET" ;; # Print exit code if not in list *): "$RET" ;; # Print exit code if not in list
esac esac
printf '%s' "$_" printf '%s' "$_"
done done
} }
__ssh() { __ssh() {
local CON=($SSH_CONNECTION) local CON=($SSH_CONNECTION)
local SRV_IP="${CON[2]}" local SRV_IP="${CON[2]}"
[[ -z "$SRV_IP" ]] && return [[ -z "$SRV_IP" ]] && return
local SRV_PORT="${CON[3]}" local SRV_PORT="${CON[3]}"
# 4 chars from startand 4 chars from end # 4 chars from startand 4 chars from end
local SRV_IP_CUT="${_CYN}${SRV_IP}" local SRV_IP_CUT="${_CYN}${SRV_IP}"
[[ ${#SRV_IP} -gt 8 ]] && local SRV_IP_CUT="${_CYN}${SRV_IP:0:4}${_WHT}*${_CYN}${SRV_IP: -4}" [[ ${#SRV_IP} -gt 8 ]] && local SRV_IP_CUT="${_CYN}${SRV_IP:0:4}${_WHT}*${_CYN}${SRV_IP: -4}"
printf '%s' "${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}" printf '%s' "${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}"
} }
__guix_env() { __guix_env() {
local re='[\(]?\("([^"]*)"' local re='[\(]?\("([^"]*)"'
if [[ "$GUIX_ENVIRONMENT" ]]; then if [[ "$GUIX_ENVIRONMENT" ]]; then
local PACKAGES=($(while read -r line; do local PACKAGES=($(while read -r line; do
[[ "$line" =~ $re ]] && printf '%s ' "${BASH_REMATCH[1]}" [[ "$line" =~ $re ]] && printf '%s ' "${BASH_REMATCH[1]}"
done < $GUIX_ENVIRONMENT/manifest)) done < $GUIX_ENVIRONMENT/manifest))
if [[ ${#PACKAGES[@]} -eq 2 ]]; then if [[ ${#PACKAGES[@]} -eq 2 ]]; then
printf "${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkg${_BLD}${_BLU}] " "${PACKAGES[0]}" "$((${#PACKAGES[@]}-1))" printf "${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkg${_BLD}${_BLU}] " "${PACKAGES[0]}" "$((${#PACKAGES[@]}-1))"
elif [[ ${#PACKAGES[@]} -gt 2 ]]; then elif [[ ${#PACKAGES[@]} -gt 2 ]]; then
printf "${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkgs${_BLD}${_BLU}] " "${PACKAGES[0]}" "$((${#PACKAGES[@]}-1))" printf "${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s ${_NON}+ ${_PRP}%d ${_NON}pkgs${_BLD}${_BLU}] " "${PACKAGES[0]}" "$((${#PACKAGES[@]}-1))"
else else
printf "${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s${_BLD}${_BLU}] " "${PACKAGES[@]}" printf "${_BLD}${_BLU}[${_NON}${_YLW}Guix${_NON}: ${_WHT}%s${_BLD}${_BLU}] " "${PACKAGES[@]}"
fi fi
fi fi
} }
__prompt() { __prompt() {
# Get exit code (must be first) # Get exit code (must be first)
local PLC=("${PIPESTATUS[@]}") local PLC=("${PIPESTATUS[@]}")
# Reset time when prompt was first displayed after command # Reset time when prompt was first displayed after command
# this contributes to the ~40 microsecond difference in $CMD_US and the actual time it took # this contributes to the ~40 microsecond difference in $CMD_US and the actual time it took
if [[ "$INC_TIME" != 0 ]]; then if [[ "$INC_TIME" != 0 ]]; then
PROMPT_RT="$EPOCHREALTIME" PROMPT_RT="$EPOCHREALTIME"
INC_TIME=0 INC_TIME=0
fi fi
# *_RT may not be set # *_RT may not be set
LAST_RT="${LAST_RT:-$EPOCHREALTIME}" LAST_RT="${LAST_RT:-$EPOCHREALTIME}"
PROMPT_RT="${PROMPT_RT:-$EPOCHREALTIME}" PROMPT_RT="${PROMPT_RT:-$EPOCHREALTIME}"
# Get relative times # Get relative times
# Remove decimal point, simulating multiplying by 1 million # Remove decimal point, simulating multiplying by 1 million
PROMPT_RT1M="${PROMPT_RT/.}" PROMPT_RT1M="${PROMPT_RT/.}"
PROMPT_RT1M="${PROMPT_RT1M/,}" PROMPT_RT1M="${PROMPT_RT1M/,}"
LAST_RT1M="${LAST_RT/.}" LAST_RT1M="${LAST_RT/.}"
LAST_RT1M="${LAST_RT1M/,}" LAST_RT1M="${LAST_RT1M/,}"
((CMD_US=PROMPT_RT1M-LAST_RT1M)) ((CMD_US=PROMPT_RT1M-LAST_RT1M))
CMD_TIME=0 CMD_TIME=0
# Divide by 1 million to get a more accurate difference # Divide by 1 million to get a more accurate difference
((CMD_TIME=CMD_US/1000000)) ((CMD_TIME=CMD_US/1000000))
[[ ${#CMD_US} -lt 6 ]] || CMD_US="${CMD_US: -6}" [[ ${#CMD_US} -lt 6 ]] || CMD_US="${CMD_US: -6}"
((CMD_US=10#$CMD_US)) ((CMD_US=10#$CMD_US))
# Set prompt sections # Set prompt sections
local SIG local SIG
local COL local COL
local UHD local UHD
local TIME local TIME
local IND local IND
local GUIX local GUIX
# Text # Text
# ssh detection and indicator # ssh detection and indicator
[[ "$SSH_CONNECTION" ]] && local SSH="$(__ssh) " [[ "$SSH_CONNECTION" ]] && local SSH="$(__ssh) "
# [INT], [4], etc. # [INT], [4], etc.
local RET local RET
for RET in "${PLC[@]}"; do for RET in "${PLC[@]}"; do
if [[ $RET -gt 0 ]]; then if [[ $RET -gt 0 ]]; then
SIG="$(printf '%s[%s%s%s] ' "$_BLU" "$_RED" "$(__sig "${PLC[@]}")" "$_BLU")" SIG="$(printf '%s[%s%s%s] ' "$_BLU" "$_RED" "$(__sig "${PLC[@]}")" "$_BLU")"
break break
fi fi
done done
# Guix shell environment # Guix shell environment
GUIX="$(__guix_env)" GUIX="$(__guix_env)"
# [user@homeserver:~] # [user@homeserver:~]
COL="$([[ $UID == 0 ]] && printf '%s' "$_RED" || printf '%s' "$_YLW")" COL="$([[ $UID == 0 ]] && printf '%s' "$_RED" || printf '%s' "$_YLW")"
UHD="${_BLD}${_BLU}[${COL}\u${_PRP}@${_CYN}\h${_PRP}:${_GRN}\w${_BLU}]" UHD="${_BLD}${_BLU}[${COL}\u${_PRP}@${_CYN}\h${_PRP}:${_GRN}\w${_BLU}]"
# 2y 351d 12m 43s 382969μs # 2y 351d 12m 43s 382969μs
TIME="${_YLW}$(__get_cmd_time)" TIME="${_YLW}$(__get_cmd_time)"
# Random colored $ or # # Random colored $ or #
_RAND256="\[\033[38;2;$((RANDOM%256));$((RANDOM%256));$((RANDOM%256))m\]" _RAND256="\[\033[38;2;$((RANDOM%256));$((RANDOM%256));$((RANDOM%256))m\]"
IND="${_RAND256}\\$" IND="${_RAND256}\\$"
# Set the prompt # Set the prompt
PS1="${_NON}${SSH}${GUIX}${SIG}${UHD} ${TIME} ${IND} ${_NON}" PS1="${_NON}${SSH}${GUIX}${SIG}${UHD} ${TIME} ${IND} ${_NON}"
} }
PROMPT_COMMAND=__prompt PROMPT_COMMAND=__prompt