Move to gnu stow
This commit is contained in:
parent
cd08a447a8
commit
9ea93f8144
120 changed files with 994 additions and 53 deletions
22
misc/dot-local/bin/block_battery
Executable file
22
misc/dot-local/bin/block_battery
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
battery=/sys/class/power_supply/BAT0
|
||||
capacity=$(cat $battery/capacity)
|
||||
bstatus=$(cat $battery/status)
|
||||
|
||||
if [ "$bstatus" = "Charging" ]; then
|
||||
symbol=
|
||||
elif [ $capacity -gt 80 ]; then
|
||||
symbol=
|
||||
elif [ $capacity -gt 60 ]; then
|
||||
symbol=
|
||||
elif [ $capacity -gt 40 ]; then
|
||||
symbol=
|
||||
elif [ $capacity -gt 20 ]; then
|
||||
symbol=
|
||||
else
|
||||
symbol=
|
||||
fi
|
||||
|
||||
echo "${symbol} ${capacity}%"
|
||||
|
||||
29
misc/dot-local/bin/change-brightness
Executable file
29
misc/dot-local/bin/change-brightness
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env sh
|
||||
# Simple script to change the system backlight. Requires a udev rules that gives the user permission
|
||||
# to the backlight folder.
|
||||
# $ change-brightness up # Increases brightness
|
||||
# $ change-brightness down # Decreases brightness
|
||||
|
||||
kernel="$(ls /sys/class/backlight/ | head -n 1)"
|
||||
dir="/sys/class/backlight/$kernel"
|
||||
|
||||
max_brightness="$(cat $dir/max_brightness)"
|
||||
brightness="$(cat $dir/brightness)"
|
||||
increment=12000
|
||||
|
||||
if [ "$1" = "down" ]; then
|
||||
new_brightness=$(($brightness - $increment))
|
||||
if [ $new_brightness -lt 0 ]; then
|
||||
new_brightness=0
|
||||
fi
|
||||
else
|
||||
new_brightness=$(($brightness + $increment))
|
||||
if [ $new_brightness -gt $max_brightness ]; then
|
||||
new_brightness=$max_brightness
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $new_brightness > $dir/brightness
|
||||
ratio=$(( (new_brightness * 100) / max_brightness ))
|
||||
notify-send -r 43 "Brightness: ${ratio}%"
|
||||
|
||||
13
misc/dot-local/bin/dlkiller
Executable file
13
misc/dot-local/bin/dlkiller
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env sh
|
||||
# For the programs that create a ~/Downloads folder on startup (ie: spotify, zoom)
|
||||
# Look in the program settings to redirect the Downloads folder before trying this solution
|
||||
# Usage: 'dlkiller $my-program'
|
||||
# Must have $SHELL variable set to your preferred shell
|
||||
|
||||
$1 &
|
||||
|
||||
sleep 4
|
||||
if [ -d ~/Downloads ] && [ -z "$(ls -A ~/Downloads)" ]; then
|
||||
rm -r ~/Downloads
|
||||
fi
|
||||
|
||||
15
misc/dot-local/bin/entrs
Executable file
15
misc/dot-local/bin/entrs
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
|
||||
accent="$ACCENT_COLOR"
|
||||
if [ -z "$accent" ]; then
|
||||
accent=blue
|
||||
fi
|
||||
|
||||
loc="$HOME/.config"
|
||||
echo "$loc/starship.def.toml" | entr sh -c "
|
||||
rm $loc/starship.toml
|
||||
sed 's/\${ACCENT_COLOR}/$accent/g' $loc/starship.def.toml > $loc/starship.toml
|
||||
notify-send 'Updated starship.toml'
|
||||
"
|
||||
|
||||
32
misc/dot-local/bin/hyprdwm
Executable file
32
misc/dot-local/bin/hyprdwm
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
# This is a script aimed at replicating the functionality of DWM where
|
||||
# there are 9 workspaces per monitor.
|
||||
|
||||
if [ ! "$1" = "goto" ] && [ ! "$1" = "moveto" ]; then
|
||||
echo "Invalid instruction"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $2 in
|
||||
''|*[!0-9]*)
|
||||
echo "Provide a number"
|
||||
exit 1
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
monitor="$(hyprctl activeworkspace | grep "monitorID:" | awk '{print $2}')"
|
||||
workspace="$(($monitor * 10 + $2))"
|
||||
hyprctl dispatch moveworkspacetomonitor "$workspace" "$monitor"
|
||||
hyprctl dispatch focusmonitor "$monitor"
|
||||
|
||||
case "$1" in
|
||||
goto)
|
||||
hyprctl dispatch workspace "$workspace"
|
||||
;;
|
||||
moveto)
|
||||
hyprctl dispatch movetoworkspace "$workspace"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
72
misc/dot-local/bin/hyprgaps
Executable file
72
misc/dot-local/bin/hyprgaps
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh
|
||||
|
||||
increase=0
|
||||
|
||||
# Reading from config
|
||||
config="$HOME/.config/hypr/hyprland.conf"
|
||||
def_gaps_out="$(grep "^\s*gaps_out" $config | awk '{print $3}')"
|
||||
[ -z "$def_gaps_out" ] && def_gaps_out=12
|
||||
def_gaps_in="$(grep "^\s*gaps_in" $config | awk '{print $3}')"
|
||||
[ -z "$def_gaps_in" ] && def_gaps_in=12
|
||||
def_rounding="$(grep "^\s*rounding" $config | awk '{print $3}')"
|
||||
[ -z "$def_rounding" ] && def_rounding=10
|
||||
|
||||
case $1 in
|
||||
-i)
|
||||
increase=1
|
||||
;;
|
||||
-d)
|
||||
increase=0
|
||||
;;
|
||||
-r)
|
||||
hyprctl keyword general:gaps_out $def_gaps_out
|
||||
hyprctl keyword general:gaps_in $def_gaps_in
|
||||
hyprctl keyword decoration:rounding $def_rounding
|
||||
exit 0
|
||||
;;
|
||||
-t)
|
||||
gaps_out="$(hyprctl getoption general:gaps_out | grep "int" | awk '{print $2}')"
|
||||
if [ $gaps_out = 0 ]; then
|
||||
hyprctl keyword general:gaps_out $def_gaps_out
|
||||
hyprctl keyword general:gaps_in $def_gaps_in
|
||||
hyprctl keyword decoration:rounding $def_rounding
|
||||
else
|
||||
hyprctl keyword general:gaps_out 0
|
||||
hyprctl keyword general:gaps_in 0
|
||||
hyprctl keyword decoration:rounding 0
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
amount="$2"
|
||||
curr_out="$(hyprctl -j getoption general:gaps_out | jq '.int')"
|
||||
|
||||
if [ $increase = 1 ]; then
|
||||
new_out=$(($curr_out + $amount))
|
||||
else
|
||||
new_out=$(($curr_out - $amount))
|
||||
fi
|
||||
|
||||
new_in="$(($new_out / 2))"
|
||||
|
||||
if [ $new_out -le 0 ] || [ $new_in -le 0 ]; then
|
||||
new_out=0
|
||||
new_in=0
|
||||
fi
|
||||
|
||||
# Handing smooth rounding transition
|
||||
notify-send "$max_rounding"
|
||||
if [ $new_in -gt $def_rounding ]; then
|
||||
new_rounding=$def_rounding
|
||||
else
|
||||
new_rounding=$new_in
|
||||
fi
|
||||
hyprctl keyword decoration:rounding "$new_rounding"
|
||||
|
||||
hyprctl keyword general:gaps_out "$new_out"
|
||||
hyprctl keyword general:gaps_in "$new_in"
|
||||
|
||||
10
misc/dot-local/bin/javafx
Executable file
10
misc/dot-local/bin/javafx
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
# I bascially had to make my own module dir in ~/.local/share/, which is partially jars
|
||||
# that I got from official downloads on the internet, and part shared object files from
|
||||
# my specific package manager, since libglass would not work otherwise.
|
||||
|
||||
java \
|
||||
--module-path ~/.local/share/jfx-sdk-17.0.9 \
|
||||
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \
|
||||
"$@"
|
||||
|
||||
14
misc/dot-local/bin/menu-accent
Executable file
14
misc/dot-local/bin/menu-accent
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
accent=$(echo "black
|
||||
red
|
||||
green
|
||||
yellow
|
||||
blue
|
||||
purple
|
||||
cyan
|
||||
white" | fuzzel --dmenu -l 8 -p "Choose an accent color:")
|
||||
[ -z "$accent" ] && exit 0
|
||||
echo "$accent" > ~/.config/colors/accent
|
||||
source ~/.config/zsh/.zshrc
|
||||
|
||||
5
misc/dot-local/bin/menu-layout
Executable file
5
misc/dot-local/bin/menu-layout
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
layout=`autorandr | fuzzel --dmenu -i -p "Select layout:" | awk '{print $1}'`
|
||||
autorandr $layout
|
||||
|
||||
11
misc/dot-local/bin/menu-man
Executable file
11
misc/dot-local/bin/menu-man
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
sel="$(man -k . | fuzzel --dmenu -i -p "Man page:")"
|
||||
[ "$sel" = "" ] && exit # Exit on no selection
|
||||
|
||||
# Selection comes in the form of:
|
||||
# $program ($num) - $desc
|
||||
# Need to run `man $num $program`
|
||||
page="$(echo "$sel" | awk -F'[()]' '{print $2" "$1}')"
|
||||
nohup $TERMINAL -e man $page >/dev/null 2>&1 &
|
||||
|
||||
7
misc/dot-local/bin/menu-run
Executable file
7
misc/dot-local/bin/menu-run
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
# Script to have rofi show and run aliases
|
||||
|
||||
rofi -rnow -show-icons -matching "prefix" \
|
||||
-display-combi "Start:" \
|
||||
-display-drun "Start:" \
|
||||
-show drun
|
||||
21
misc/dot-local/bin/menu-unicode
Executable file
21
misc/dot-local/bin/menu-unicode
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# The famous "get a menu of emojis to copy" script.
|
||||
|
||||
# Get user selection via dmenu from emoji file.
|
||||
chosen=$(cut -d ';' -f1 ~/.local/share/chars/* | dmenu -i -l 30 | sed "s/ .*//")
|
||||
|
||||
# Exit if none chosen.
|
||||
[ -z "$chosen" ] && exit
|
||||
|
||||
# If you run this command with an argument, it will automatically insert the
|
||||
# character. Otherwise, show a message that the emoji has been copied.
|
||||
if [ "$1" = "type" ]; then
|
||||
xdotool type "$chosen"
|
||||
elif [ "$1" = "output" ]; then
|
||||
echo "$chosen"
|
||||
else
|
||||
printf "%s" "$chosen" | xclip -selection clipboard
|
||||
notify-send "'$chosen' copied to clipboard." &
|
||||
fi
|
||||
|
||||
43
misc/dot-local/bin/menu-wpio
Executable file
43
misc/dot-local/bin/menu-wpio
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
# Simple rofi script for changing default audio sink
|
||||
|
||||
audio_info="$(wpctl status \
|
||||
| awk '/Audio/,/Video/ {print}')"
|
||||
|
||||
case $1 in
|
||||
sink)
|
||||
section="$(echo "$audio_info" \
|
||||
| awk '/Sinks:/,/Sink endpoints:/ {print}')"
|
||||
;;
|
||||
source)
|
||||
section="$(echo "$audio_info" \
|
||||
| awk '/Sources:/,/Source endpoints:/ {print}')"
|
||||
;;
|
||||
*)
|
||||
echo "Aguments must be one of (sink|source)."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
devices_and_numbers="$(echo "$section" \
|
||||
| tail -n +2 | head -n -2 | cut -c 10-)"
|
||||
|
||||
devices="$(echo "$devices_and_numbers" \
|
||||
| awk -F'.' '{print $2}' \
|
||||
| awk -F'[' '{print $1}' \
|
||||
| cut -c 2-)"
|
||||
|
||||
lines="$(echo "$devices" | wc -l)"
|
||||
chosen="$(echo "$devices" | fuzzel -l $lines --dmenu -p "Select audio $1:" -i)"
|
||||
if [ -z "$chosen" ]; then
|
||||
# Exited without selecting
|
||||
exit
|
||||
fi
|
||||
|
||||
number="$(echo "$devices_and_numbers" \
|
||||
| grep "$chosen" \
|
||||
| awk '{print $1}' \
|
||||
| sed 's/\./ /')"
|
||||
|
||||
wpctl set-default $number
|
||||
|
||||
102
misc/dot-local/bin/opener
Executable file
102
misc/dot-local/bin/opener
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/env sh
|
||||
# Script for opening a file, intended for use by a terminal file manager.
|
||||
|
||||
# Whether to open in a new window
|
||||
detatch=0
|
||||
[ "$1" = "detatch" ] && detatch=1 && shift 1
|
||||
|
||||
# First arg must be a file
|
||||
[ ! -f "$1" ] && echo "Not a file: '$1'" && exit 1
|
||||
|
||||
function launch_gui() {
|
||||
if [ "$detatch" -eq 0 ]; then
|
||||
[ -n "$WAYLAND_DISPLAY" ] \
|
||||
&& precmd="swallow" `# For Hyprland` \
|
||||
|| precmd="devour" # For X
|
||||
else
|
||||
precmd="setsid -f"
|
||||
fi
|
||||
|
||||
$precmd "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
function launch_term() {
|
||||
if [ "$detatch" -eq 1 ]; then
|
||||
# This is a bit of a hack. Shell only expects a single argument into
|
||||
# the -c flag, so it needs to be wrapped in quotes. However, if "$@"
|
||||
# wher passed in with `mpv "my file.mp3"`, it would not preserve the
|
||||
# $2 having a space and would instead split it up into 3 arguments
|
||||
# into the new shell. Wrapping everything argument in quotes is the
|
||||
# only general solution I could come up with.
|
||||
command_string=""
|
||||
while [ $# -gt 0 ]; do
|
||||
command_string="$command_string \"$1\""
|
||||
shift
|
||||
done
|
||||
setsid -f $TERMINAL -e $SHELL -c "$command_string; exec $SHELL" >/dev/null 2>&1
|
||||
else
|
||||
clear
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
case $(file --mime-type "$1" -b) in
|
||||
application/javascript|\
|
||||
application/json|\
|
||||
application/pgp-encrypted|\
|
||||
application/x-subrip|\
|
||||
inode/x-empty|\
|
||||
text/*)
|
||||
case "${1##*.}" in
|
||||
org|typ)
|
||||
# Any "document" like file ought to be in emacs
|
||||
launch_gui emacsclient -c "$1"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
launch_term nvim "$1"
|
||||
;;
|
||||
image/*)
|
||||
launch_gui nsxiv "$1"
|
||||
;;
|
||||
video/*)
|
||||
launch_gui mpv -quiet "$1"
|
||||
;;
|
||||
application/epub*|\
|
||||
application/octet-stream|\
|
||||
application/pdf|\
|
||||
application/postscript|\
|
||||
application/vnd.djvu|\
|
||||
image/vnd.djvu)
|
||||
launch_gui zathura "$1"
|
||||
;;
|
||||
audio/*|\
|
||||
video/x-ms-asf)
|
||||
[ -z "$(mediainfo "$1" | grep "Cover\s*: Yes")" ] \
|
||||
&& (launch_term mpv --audio-display=no "$1") \
|
||||
|| (launch_gui mpv "$1")
|
||||
;;
|
||||
application/msword|\
|
||||
application/octet-stream|\
|
||||
application/vnd.ms-powerpoint|\
|
||||
application/vnd.oasis.opendocument.database|\
|
||||
application/vnd.oasis.opendocument.formula|\
|
||||
application/vnd.oasis.opendocument.graphics|\
|
||||
application/vnd.oasis.opendocument.graphics-template|\
|
||||
application/vnd.oasis.opendocument.presentation|\
|
||||
application/vnd.oasis.opendocument.presentation-template|\
|
||||
application/vnd.oasis.opendocument.spreadsheet|\
|
||||
application/vnd.oasis.opendocument.spreadsheet-template|\
|
||||
application/vnd.oasis.opendocument.text|\
|
||||
application/vnd.openxmlformats-officedocument.presentationml.presentation|\
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|\
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document)
|
||||
launch_gui libreoffice "$1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
27
misc/dot-local/bin/overrides/nixos-rebuild
Executable file
27
misc/dot-local/bin/overrides/nixos-rebuild
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Since the below command is piped into nom, it has weird output if the sudo password
|
||||
# has to be prompted. Add a dummy command to make sure a valid token exists (assuming the
|
||||
# user's sudo config saves sudo password for some time after entry)
|
||||
sudo echo >/dev/null
|
||||
|
||||
function last_two_builds {
|
||||
ls -v1 /nix/var/nix/profiles | tail -n 2
|
||||
}
|
||||
|
||||
before="$(last_two_builds)"
|
||||
|
||||
sudo \
|
||||
unbuffer `# Preserve colors when piping into nom` \
|
||||
sysbin `# Use the system's nixos-rebuild (as opposed to running this script again)` \
|
||||
nixos-rebuild "$@" `# Rebuild` \
|
||||
|& nom `# Visualize a live dependency graph while building`
|
||||
|
||||
after="$(last_two_builds)"
|
||||
if [ "$before" = "$after" ]; then
|
||||
exit 0 # No new build happened
|
||||
fi
|
||||
|
||||
# Print diff between last two builds
|
||||
ls -v1 /nix/var/nix/profiles | tail -n 2 | awk '{print "/nix/var/nix/profiles/" $0}' - | xargs nvd diff
|
||||
|
||||
6
misc/dot-local/bin/overrides/rofi-pass
Executable file
6
misc/dot-local/bin/overrides/rofi-pass
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
# Passes a userdata var, which will eventually be passed to pinentry-wrapper, and open
|
||||
# pinentry-rofi to enter the decryption password
|
||||
|
||||
PINENTRY_USER_DATA=rofi sysbin rofi-pass
|
||||
|
||||
17
misc/dot-local/bin/pinentry-wrapper
Executable file
17
misc/dot-local/bin/pinentry-wrapper
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Defaults to Qt, with a choice of curses for selected programs
|
||||
# PINENTRY_USER_DATA is a GnuPG defined variable (see man gpg)
|
||||
|
||||
case "$PINENTRY_USER_DATA" in
|
||||
dmenu)
|
||||
exec pinentry-dmenu "$@"
|
||||
;;
|
||||
rofi)
|
||||
exec pinentry-rofi "$@"
|
||||
;;
|
||||
*)
|
||||
exec pinentry-curses "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
13
misc/dot-local/bin/rotdir
Executable file
13
misc/dot-local/bin/rotdir
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# When I open an image from the file manager in nsxiv (the image viewer), I want
|
||||
# to be able to press the next/previous keys to key through the rest of the
|
||||
# images in the same directory. This script "rotates" the content of a
|
||||
# directory based on the first chosen file, so that if I open the 15th image,
|
||||
# if I press next, it will go to the 16th etc. Autistic, I know, but this is
|
||||
# one of the reasons that nsxiv is great for being able to read standard input.
|
||||
|
||||
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
||||
base="$(basename "$1")"
|
||||
ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'
|
||||
|
||||
10
misc/dot-local/bin/swallow
Executable file
10
misc/dot-local/bin/swallow
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
# Window swallower for Hyprland
|
||||
|
||||
pid=$(hyprctl activewindow -j | jq '.pid')
|
||||
workspace=$(hyprctl activeworkspace -j | jq '.id')
|
||||
|
||||
hyprctl dispatch movetoworkspacesilent special
|
||||
cmd=$1; shift 1; $cmd "$@"
|
||||
hyprctl dispatch movetoworkspacesilent "$workspace",pid:"$pid"
|
||||
|
||||
30
misc/dot-local/bin/sysbin
Executable file
30
misc/dot-local/bin/sysbin
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env sh
|
||||
# Finds the absolute path of a system binary by checking places in most-likely order.
|
||||
# Helpful for when overriding a binary with a script, meaning the script takes higher
|
||||
# precedence in the path, but then the script needs to call the actual binary.
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
# No program prvided
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Split the custom path into an array based on ":" (path separator)
|
||||
IFS=":" read -ra path_dirs <<< "$PATH"
|
||||
|
||||
# Iterate through the directories in PATH_2
|
||||
for dir in "${path_dirs[@]}"; do
|
||||
if [ "$(echo "$dir" | cut -c 1)" = "~" ] || [ "$(echo "$dir" | cut -c 1-5)" = "/home" ]; then
|
||||
# We are looking in a user's home, skip.
|
||||
continue
|
||||
fi
|
||||
|
||||
potential_path="$dir/$1"
|
||||
if [ -x "$potential_path" ]; then
|
||||
"$dir/$@"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo "command not found: $1"
|
||||
exit 2 # Not found
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue