New directory structure + basilisk

This commit is contained in:
2026-01-12 19:32:18 -07:00
parent 298eb76909
commit ff69bb8284
316 changed files with 2467 additions and 1375 deletions

View File

@@ -0,0 +1,52 @@
#!/bin/env bash
path="$HOME/.config/bspwm/bspwmrc"
tmp=$(mktemp)
primary=$(xrandr | grep " connected" | rofi -dmenu -a | awk '{ print $1 }')
secondary=$(xrandr | grep " connected" | grep -v "^$primary" | awk '{ print $1 }')
use_secondary=$(printf 'Yes\nNo\n' | rofi -dmenu -e "Use secondary displays?" -format i)
p() {
if [ -n "$secondary" ] && [ "$use_secondary" == 0 ]; then
printf 'bspc monitor %s -d I II III IV\n' "$primary"
printf 'bspc monitor %s -d %s\n' "$secondary" "$secondary"
else
printf 'bspc monitor %s -d I II III IV V\n' "$primary"
bspc monitor "$secondary" -r
fi
}
p | awk -v blockstart="# START MONITOR BLOCK" \
-v blockend="# END MONITOR BLOCK" \
-v sq="'" \
-v nl="\n" '
FILENAME == "-" {
block=block $0 nl
next
}
!inblock { print }
inblock {
lines[++bi] = $0
}
$0 ~ blockstart {
inblock = 1;
bi = 0;
printf block
next
}
$0 == blockend && inblock {
inblock = 0;
print blockend;
next;
}
ENDFILE {
if(inblock) {
print nl blockend;
for(i=1;i<=bi;i++) {
print lines[i];
}
}
}
' - "$path" > "$tmp" && mv "$tmp" "$path"
chmod +x "$path"
"$path"

3
home/.local/bin/bsp-float Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
# Open a command in float mode
bspc rule -a \* -o state=floating && $@

View File

@@ -0,0 +1,14 @@
#!/bin/bash
if [ ! -z $1 ]; then
# FLOATING_DESKTOP_ID=$(bspc query -D -d '^3')
FLOATING_DESKTOP_ID=$1
bspc subscribe node_add | while read -a msg ; do
desk_id=${msg[2]}
wid=${msg[4]}
[ "$FLOATING_DESKTOP_ID" = "$desk_id" ] && bspc node "$wid" -t floating
done
else
echo "No desktop provided"
fi

6
home/.local/bin/bsp-key-daemon Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
# Make sure user bin is imported for sxhkd
PATH="/home/dakedres/bin:$PATH"
pgrep -x sxhkd > /dev/null || sxhkd &

60
home/.local/bin/bsp-smove Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
# A more fluid way of moving windows with BSPWM, which is meant to be
# implemented in SXHKD. If there is a window in the given direction,
# swap places with it. Else if there is a receptacle move to it
# ("consume" its place). Otherwise create a receptacle in the given
# direction by splitting the entire viewport (circumvents the tiling
# scheme while respecting the current split ratio configuration). In
# the latter scenario, inputting the direction twice will thus move the
# focused window out of its current layout and into the receptacle.
#
# Part of my dotfiles: https://gitlab.com/protesilaos/dotfiles
#
# Copyright (c) 2019 Protesilaos Stavrou <info@protesilaos.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
[ "$#" -eq 1 ] || { echo "Pass only one argument: north,east,south,west"; exit 1; }
# Check if argument is a valid direction.
case "$1" in
north|east|south|west)
dir="$1"
;;
*)
echo "Not a valid argument."
echo "Use one of: north,east,south,west"
exit 1
;;
esac
_query_nodes() {
bspc query -N -n "$@"
}
# Do not operate on floating windows!
[ -z "$(_query_nodes focused.floating)" ] || { echo "Only move tiled windows."; exit 1; }
receptacle="$(_query_nodes 'any.leaf.!window')"
# This regulates the behaviour documented in the description.
if [ -n "$(_query_nodes "${dir}.!floating")" ]; then
bspc node -s "$dir"
elif [ -n "$receptacle" ]; then
bspc node focused -n "$receptacle" --follow
else
bspc node @/ -p "$dir" -i && bspc node -n "$receptacle" --follow
fi

17
home/.local/bin/bsp-status Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
declare -A layout_symbols
layout_symbols[monocle]="mono"
layout_symbols[tiled]="tiled"
send_symbol() {
echo ${layout_symbols[$1]}
}
# Optional, sends first output. This requires jq
send_symbol $(bspc query -T --desktop focused | jq -r '.layout')
bspc subscribe desktop_layout | while read -a msg ; do
send_symbol ${msg[3]}
done

View File

@@ -0,0 +1,37 @@
#!/bin/bash
if [ $# = 0 ]; then
cat <<EOF
Usage: $(basename "${0}") process_name [executable_name] [--take-first]
process_name As recognized by 'xdo' command
executable_name As used for launching from terminal
--take-first In case 'xdo' returns multiple process IDs
EOF
exit 0
fi
# Get id of process by class name and then fallback to instance name
id=$(xdo id -N "${1}" || xdo id -n "${1}")
executable=${1}
shift
while [ -n "${1}" ]; do
case ${1} in
--take-first)
id=$(head -1 <<<"${id}" | cut -f1 -d' ')
;;
*)
executable=${1}
;;
esac
shift
done
if [ -z "${id}" ]; then
${executable}
else
while read -r instance; do
bspc node "${instance}" --flag hidden --to-monitor focused --focus
done <<<"${id}"
fi

55
home/.local/bin/change-scheme Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Favorites:
# - horizon-terminal-dark
# - heetch
# - blueforest
# - tarot
if [[ -n "$1" ]]; then
export SCHEME=$1
fi
if [ ! -r "$(shchemes path)" ]; then
if ! shchemes install_tinted_scheme; then
exit 1
fi
fi
# shchemes inject "$HOME/.profile"
shchemes inject "$HOME/.config/qutebrowser/config.py"
shchemes create_theme css > "$HOME/.config/base16.css"
shchemes create_theme css > "$HOME/.config/qutebrowser/base16.css"
pkill -HUP qutebrowser
shchemes create_theme xfce4-terminal | sh
shchemes create_theme i3 > "$HOME/.config/i3/theme"
i3-msg reload
shchemes create_theme rofi > "$HOME/.config/rofi/theme.rasi"
shchemes create_theme better-discord > "$HOME/.config/vesktop/themes/theme.css"
# shchemes create_theme obsidian > "$HOME/media/vault/.obsidian/themes/base16.css"
# "$HOME/repos/oomox-gtk-theme/change_color.sh" -o base16 <(shchemes create_theme oomox-gtk)
# Reload XFCE theme
# xfconf-query -c xsettings -p /Net/ThemeName -r
# xfconf-query -c xsettings -p /Net/ThemeName -s base16
xrandr | awk '$2 == "connected" { system("le-wallpaper " $1) }'
# WALLPAPER_OUT="$HOME/.wallpaper.png"
# shchemes create_theme imagemagick \
# | convert ~/pictures/wallpapers/tradin.jpg -dither FloydSteinberg -colorspace srgb -remap txt:- "$WALLPAPER_OUT"
# feh --bg-scale "$WALLPAPER_OUT"
# terminal=$(ps -o comm= -p "$(($(ps -o ppid= -p "$(($(ps -o sid= -p "$$")))")))")
# if [[ "$terminal" == "kitty" ]]; then
# tmp=$(mktemp)
# shchemes create_theme imagemagick \
# | convert txt:- -filter point -resize 2400% "$tmp"
# kitty +kitten icat "$tmp"
# fi

5
home/.local/bin/ezmount Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
sudo mkdir /media/$USER/$1
sudo mount /dev/$1 /media/$USER/$1
sudo chown $(id -u $USER) /media/$USER/$1

29
home/.local/bin/f Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
path=$1
if [ -z "$path" ]; then
path="."
fi
if [ -d "$path" ]; then
ls -lha --color=tty "$path"
else
if [ ! -f "$path" ]; then
echo "No such file: $path"
exit 0
fi
format="$(file -i "$path" | cut -d' ' -f2)"
format="${format%%/*}"
case "$format" in
"image")
kitty +kitten icat "$path"
;;
*)
cat "$path"
;;
esac
fi

162
home/.local/bin/le-audio Executable file
View File

@@ -0,0 +1,162 @@
#!/bin/sh
get_cards() {
pacmd list-cards | awk -F '[\t ]+' '
function printcard() {
print cardindex " " cardname " " carddesc
}
$2 ~ "index:" {
if(incard) {
printcard()
}
incard=1
cardindex=$3
}
incard && $2 ~ "name:" {
cardname=substr($3, 2, length($3) - 2)
}
incard && $2 ~ "device.description" {
carddesc=substr($0, index($0, "= ") + 2)
}
END {
printcard()
}
'
}
# First line will always be the active profile
get_selected_card_profiles() {
pacmd list-cards | awk -F '[\t ]+' \
-v selected_card_index="$selected_card_index" '
BEGIN {
profile_count=0
}
function print_card() {
if(do_print) {
print profile_names[i] " " profile_descs[i]
}
}
$2 ~ "index:" && $3 == selected_card_index {
incard=1
}
incard && $2 ~ "profiles:" {
inprofiles=1
next
}
inprofiles && $2 ~ "active" {
for(i = 0; i < profile_count; i++) {
if(profile_names[i] == substr($4, 2, length($4) - 2)) {
current_card_index=i
do_print=1
}
print_card()
}
for(i = 0; i < current_card_index; i++) {
print_card()
}
exit
}
inprofiles {
profile_names[profile_count] = substr($2, 0, length($2) - 1)
profile_descs[profile_count] = substr($0, index($0, ": ") + 2)
profile_count++
}
'
}
select_default_sink_card() {
selected_card=$(pacmd list-sinks | awk -F '[\t ]+' '
$2 == "*" && $3 ~ "index:" {
incard=1
}
incard && $2 == "card:" {
print $3 " " substr($4, 2, length($4) - 2)
exit
}
')
}
select_card_manually() {
card_options=$(get_cards)
selected_option_index=$(printf %s\\n "$card_options" | rofi -dmenu -format 'i')
selected_option_index=$((selected_option_index+1))
selected_card=$(printf %s\\n "$card_options" | sed -n "${selected_option_index}p")
}
print_usage() {
printf '
Usage: le-audio [OPTIONS]
Manage audio profiles
Options
-a Auto - Auto-select the card for the default sink
-f Filter - Filter out "off" profiles
-c Cycle - Auto-select the next audio profile after the current one
Utility written by Dakedres (dakedres.sys42.net)
'
}
while getopts 'afc' args; do
case "$args" in
a)
arg_auto_select_card=true
;;
f)
arg_filter_off_profile=true
;;
c)
arg_select_next_profile=true
;;
?)
print_usage
exit
;;
*)
>&2 echo "Invalid option '${args}'"
esac
done
if [ "$arg_auto_select_card" = true ]; then
select_default_sink_card
else
select_card_manually
fi
selected_card_index=$(printf %s\\n "$selected_card" | awk '{ print $1 }')
echo "$selected_card"
if [ "$arg_filter_off_profile" = true ]; then
selected_card_profiles=$(get_selected_card_profiles | grep -v '^off')
else
selected_card_profiles=$(get_selected_card_profiles)
fi
if [ "$arg_select_next_profile" = true ]; then
selected_profile_index=1
else
selected_profile_index=$(printf %s\\n "$selected_card_profiles" | rofi -dmenu -format "i")
fi
if [ -z "$selected_profile_index" ]; then
>&2 echo "No profile selected"
exit 1
fi
printf %s\\n "$selected_card_profiles" | awk \
-v selected_profile_index="$selected_profile_index" \
-v selected_card="$selected_card" \
-v qt="'" '
NR-1 == selected_profile_index {
split(selected_card, split_card, " ")
printf "pactl set-card-profile" " " split_card[1] " " $1
$1=""
print " && notify-send " qt "Set audio profile to" $0 qt
}
' | sh

2
home/.local/bin/le-keyboard Executable file
View File

@@ -0,0 +1,2 @@
# setxkbmap -option altwin:swap_alt_win
setxkbmap -option caps:swapescape

63
home/.local/bin/le-wallpaper Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/env bash
if [ -f "$HOME/.profile" ]; then
source "$HOME/.profile"
fi
monitor=($(xrandr | awk -v name="$1" '$1 == name && $2 == "connected" {
for(i=1;i<=NF;i++) {
if($i ~ /[0-9]+x[0-9]+\+[0-9]+\+[0-9]+/) {
split($i, a, /[+x]/); print $1 " " a[1] " " a[2]; exit
}
}
}'))
monitor_name="${monitor[0]}"
monitor_width="${monitor[1]}"
monitor_height="${monitor[2]}"
prop="/backdrop/screen0/monitor${monitor_name}/workspace0/last-image"
path="$2"
wallpaper_dir="$HOME/.local/share/le_wallpaper"
wallpaper_path="${wallpaper_dir}/.${monitor_name}.png"
wallpaper_store="${wallpaper_dir}/${monitor_name}_path"
mkdir -p "$wallpaper_dir"
if [ -z "$path" ]; then
path="$(xfconf-query -c xfce4-desktop -p "$prop")"
if [[ ! "$path" = /* ]]; then
path="${HOME}/${path}"
fi
fi
if [ "$path" == "$wallpaper_path" ]; then
path=$(cat "$wallpaper_store")
fi
# path="$(readlink -f "$path")"
if [ ! -f "$path" ]; then
echo "No wallpaper source"
exit 0
fi
filename=$(basename -- "$path")
ext="${filename##*.}"
# The following always assumes the monitor is landscape
if [ "$ext" == "svg" ] && command -v inkscape; then
tmp="$(mktemp).png"
inkscape -h "$monitor_height" "$path" -o "$tmp"
path="$tmp"
fi
export SCHEME
shchemes create_theme imagemagick \
| convert "$path" -colorspace srgb -dither FloydSteinberg -geometry "${monitor_width}x" -remap txt:- "$wallpaper_path"
echo "Setting wallpaper: $path"
xfconf-query -c xfce4-desktop -p "$prop" -s "$wallpaper_path"
echo "$path" > "$wallpaper_store"
le-wallpaper-open

View File

@@ -0,0 +1,32 @@
#!/bin/sh
xrandr | awk '
function addWallpaper(i) {
split($3, a, "+");
b[bi] = a[2];
c[bi] = $1;
bi++
}
$2 == "connected" {
for(i=1;i<=NF;i++) {
if($i ~ /[0-9]+x[0-9]+\+[0-9]+\+[0-9]+/) {
addWallpaper(i);
}
}
}
END {
PROCINFO["sorted_in"] = "@val_num_asc";
d = "feh --bg-center";
for(i in b) {
p="$HOME/.local/share/le_wallpaper/." c[i] ".png";
if(system("test -f " p)) {
p = lp;
}
lp = p;
d=d " " p;
}
system(d);
}
'

6
home/.local/bin/mdread Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
o="$(mktemp).html"
t="$(basename $1)"
pandoc "$1" -o "$o" --metadata="title:$t"
xdg-open "$o"

1830
home/.local/bin/pfetch Executable file

File diff suppressed because it is too large Load Diff

7
home/.local/bin/qutesearch Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
db=$HOME/.local/share/qutebrowser/history.sqlite
url=$(sqlite3 "$db" "select title,url from History" | tac | awk '!a[$0]++' | rofi -dmenu | awk -F '|' '{print $NF}')
[ -z "$url" ] && exit
qutebrowser "$url"

2
home/.local/bin/rack Executable file
View File

@@ -0,0 +1,2 @@
cd $HOME/apps/Rack2Free
./Rack

9
home/.local/bin/rofi-ask Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
# Take password prompt from STDIN, print password to STDOUT
# the sed piece just removes the colon from the provided
# prompt: rofi -p already gives us a colon
rofi -dmenu \
-password \
-no-fixed-num-lines \
-p "$(printf "$1" | sed s/://)"

5
home/.local/bin/sxhkd-help Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
awk '/^[a-z]/ && last {print "<small>",$0,"\t",last,"</small>"} {last=""} /^#/{last=$0}' ~/.config/sxhkd/sxhkdrc{,.common} |
column -t -s $'\t' |
rofi -dmenu -i -markup-rows -no-show-icons -width 1000 -lines 15

View File

@@ -0,0 +1,9 @@
#!/bin/bash
id=$(bspc query -N -n);
if [ "$(tabc printclass $id)" == "tabbed" ]; then
bspc node -p $1;
tabc detach $id;
else \
tabc attach $id $(bspc query -N -n $1);
fi

2
home/.local/bin/web Executable file
View File

@@ -0,0 +1,2 @@
echo "$1"
chromium --new-window --app="$1"

View File

@@ -0,0 +1,10 @@
#!/bin/env bash
# xrandr | awk '$2 == "connected" && $3 ~ /[0-9]+x[0-9]+\+[0-9]+\+[0-9]+/ { split($3, a, "+"); b[bi] = a[2]; c[bi] = $1; bi++ } END { PROCINFO["sorted_in"] = "@val_num_asc"; d = "feh --bg-center"; for(i in b) { d=d " $HOME/.local/share/le_wallpaper/" c[i] ".png" }; system(d) }'
le-wallpaper-open
xfconf-query -c xfce4-desktop -m | awk -F '/' '
$2 == "backdrop" && $3 == "screen0" && $4 ~ /^monitor/ {
system("le-wallpaper " substr($4, 8))
}'

View File

@@ -0,0 +1,8 @@
[Desktop Entry]
Name=Bitwarden
Comment=Bitwarden
Exec=/home/dakedres/bin/bitwarden
Icon=/home/dakedres/pictures/icons/bitwarden-128.png
Terminal=false
Type=Application
Categories=Security;

View File

@@ -0,0 +1,8 @@
[Desktop Entry]
Name=Intellij IDEA Community Edition
Comment=java L
Exec=/opt/idea-IC-243.26053.27/bin/idea
Icon=/home/dakedres/repos/dotfiles/icons/intellij-idea-128.png
Terminal=false
Type=Application
Categories=Security;

View File

@@ -0,0 +1,9 @@
[Desktop Entry]
Name=VCV Rack
Comment=Modular Synthesis Emulator
Keywords=audio;sound;jackd;synth;
Exec=/home/dakedres/bin/rack
Terminal=false
Type=Application
Icon=/home/dakedres/pictures/icons/vcv-rack-128.png
Categories=AudioVideo;Audio;

View File

@@ -0,0 +1,67 @@
#!/usr/bin/env python3
# copy-bookmark
# copies links to specific headers/elements of a page
# by Dakedres
#
# I guessed at how Python works.
# Based on https://github.com/LaurenceWarne/qute-code-hint/blob/master/code_select.py
# It is recommended you add this to your config.py to use this script:
# c.hints.selectors["bookmarks"] = [
# "h1[id]",
# "h2[id]",
# "h3[id]",
# "h4[id]",
# "h5[id]",
# "h6[id]",
# "h1 > a[id]",
# "h2 > a[id]",
# "h3 > a[id]",
# "h4 > a[id]",
# "h5 > a[id]",
# "h6 > a[id]",
# "header[id]",
# "footer[id]",
# "article[id]",
# "section[id]",
# "p[id]",
# "div[itemtype=\"https://schema.org/Answer\"]" # Stackoverflow answers
# ]
# And call it with
# hint bookmarks userscript copy-bookmark
import os
from urllib.parse import urlparse, urlunparse
from html.parser import HTMLParser
class BookmarkParser(HTMLParser):
def handle_starttag(self, tag, attrs):
for attr in attrs:
print(attr[0])
if(attr[0] == "id"):
self.bookmark_id = attr[1]
def close(self):
HTMLParser.close(self)
return self.bookmark_id
def send_to_qute(command):
with open(os.environ.get("QUTE_FIFO"), "w") as f:
f.write(command)
def construct_bookmark_url():
parser = BookmarkParser()
parser.feed(os.environ.get("QUTE_SELECTED_HTML"))
bookmark_id = parser.close()
url = urlparse(os.environ.get("QUTE_CURRENT_URL") )
url = url._replace(fragment=bookmark_id)
return urlunparse(url)
def main():
send_to_qute("yank inline '{url}'".format(url=construct_bookmark_url() ) )
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,47 @@
#!/bin/sh
mode=$1
index=0
if [ -z "$mode" ]; then
mode="eval"
fi
printf %s\\n 'message-info "Requesting password..."' >> "$QUTE_FIFO"
results=$(bw list items --session --url "$QUTE_CURRENT_URL")
query() {
printf %s "$results" | jq "$1"
}
if [ "$(query length)" != 1 ]; then
index=$(query ".[] | .name,.login.username" | tr -d '"' | awk '!(NR%2){print $0 " (" p ")"}{p=$0}' | rofi -dmenu -format i)
fi
password="$(query ".[${index}].login.password" | tr -d '"')"
case $mode in
eval)
username="$(query ".[${index}].login.username" | tr -d '"')"
script=$(printf %s """\
let e = document.activeElement, \
f = e.closest('form'), \
p = !f || e.type === 'password' ? e : f.querySelector('input[type=password]'), \
u = !f || e.type === 'email' || e.type === 'text' ? e : f.querySelector('input[type=email], input[name=email], input[name=username], input[name=user_name], input[name=user], input[autofocus]'), \
F = (i, v) => { if(i) { i.value = v; return true } }, \
su = F(u, USERNAME), \
sp = F(p, PASSWORD); \
if(su && sp) { 'Login filled' } \
else if(su) { 'Username filled' } \
else if(sp) { 'Password filled' } \
else 'Unable to fill login info' \
""")
command="jseval $(printf '{ let USERNAME="%s", PASSWORD="%s"; %s }' "$username" "$password" "$script" )"
;;
*)
command="insert-text ${password}"
;;
esac
printf %s\\n "$command" > "$QUTE_FIFO"

View File

@@ -0,0 +1,27 @@
#!/bin/bash
# pipe=/tmp/testpipe
# trap "rm -f $pipe" EXIT
#
# if [[ ! -p $pipe ]]; then
# mkfifo $pipe
# fi
# echo "$QUTE_FIFO" > $HOME/fifoa
#
# echo "jseval window.location.href"
#
# while true
# do
# if read -r line <"$QUTE_FIFO"; then
# if [[ "$line" == 'quit' ]]; then
# break
# fi
# echo "$line"
# fi
# done
#
# echo "Reader exiting"
echo "open -t https://www.dict.cc/?s=$QUTE_SELECTED_TEXT" >> "$QUTE_FIFO"