|
diff --git a/.newsboat/urls b/.newsboat/urls
|
|
|
1 |
https://theorangeduck.com/feeds/pages |
|
|
2 |
https://lwn.net/headlines/rss |
|
|
3 |
https://kristoff.it/index.xml |
|
|
4 |
https://www.computerenhance.com/feed |
|
|
5 |
https://tratt.net/laurie/news.rss |
|
|
6 |
https://willhbr.net/feed.xml |
|
|
7 |
https://andrewkelley.me/rss.xml |
|
|
8 |
https://beyondloom.com/blog/rss.xml |
|
|
9 |
https://thomashunter.name/feed.rss |
|
|
10 |
https://decuser.github.io/feed.xml |
|
|
11 |
https://simonwillison.net/atom/entries/ |
|
|
12 |
https://til.simonwillison.net/tils/feed.atom |
|
|
13 |
https://www.andreinc.net/feed.xml |
|
|
14 |
https://voussoir.net/writing/writing.atom |
|
|
15 |
https://blog.regehr.org/feed |
|
|
16 |
https://richiejp.com/atom.xml |
|
|
17 |
https://szymonkaliski.com/feed.xml |
|
|
18 |
https://world.hey.com/dhh/feed.atom |
|
|
19 |
https://mitchellh.com/feed.xml |
|
|
20 |
https://matt-rickard.com/rss |
|
|
21 |
https://neil.computer/rss/ |
|
|
22 |
https://matduggan.com/rss/ |
|
|
23 |
https://michael.stapelberg.ch/feed.xml |
|
|
24 |
https://journal.valeriansaliou.name/rss/ |
|
|
25 |
https://www.duskborn.com/index.xml |
|
|
26 |
https://mirzapandzo.com/rss.xml |
|
|
27 |
https://mitjafelicijan.com/feed.xml |
|
|
28 |
https://crawl.develz.org/wordpress/feed |
|
|
29 |
https://go.dev/blog/feed.atom |
|
|
30 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCYO_jab_esuFRV4b17AJtAw |
|
|
31 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCUSck1dOH7VKmG4lRW7tZXg |
|
|
32 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCkK9UDm_ZNrq_rIXCz3xCGA |
|
|
33 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCwgKmJM4ZJQRJ-U5NjvR2dg |
|
|
34 |
https://www.youtube.com/feeds/videos.xml?channel_id=UC8DntJ-sBtgC-jA0yEjxqjw |
|
|
35 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCrqM0Ym_NbK1fqeQG2VIohg |
|
|
36 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCUzQJ3JBuQ9w-po4TXRJHiA |
|
|
37 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCUyeluBRhGPCW4rPe_UvBZQ |
|
|
38 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCS0N5baNlQWJCUrhCEo8WlA |
|
|
39 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCsBjURrPoezykLs9EqgamOA |
|
|
40 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCaTznQhurW5AaiYPbhEA-KA |
|
|
41 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCld68syR8Wi-GY_n4CaoJGA |
|
|
42 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCXuqSBlHAE6Xw-yeJA0Tunw |
|
|
43 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCVk4b-svNJoeytrrlOixebQ |
|
|
44 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCNzszbnvQeFzObW0ghk0Ckw |
|
|
45 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCAMu6Dso0ENoNm3sKpQsy0g |
|
|
46 |
https://www.youtube.com/feeds/videos.xml?channel_id=UC2DjFE7Xf11URZqWBigcVOQ |
|
|
47 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCVls1GmFKf6WlTraIb_IaJg |
|
|
48 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCTAfm-YD2M9xzvbYvRc5ttA |
|
|
49 |
https://www.youtube.com/feeds/videos.xml?channel_id=UC5--wS0Ljbin1TjWQX6eafA |
|
|
50 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCmtyQOKKmrMVaKuRXz02jbQ |
|
diff --git a/.shenanigans.sh b/.shenanigans.sh
|
|
|
1 |
# Magical environment variables. |
|
|
2 |
NIX_SHELL_PRESERVE_PROMPT=1 |
|
|
3 |
TERM=xterm-256color |
|
|
4 |
VISUAL=vim |
|
|
5 |
EDITOR=vim |
|
|
6 |
|
|
|
7 |
parse_git_branch() { |
|
|
8 |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' |
|
|
9 |
} |
|
|
10 |
|
|
|
11 |
is_inside_nix_shell() { |
|
|
12 |
nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)" |
|
|
13 |
if [[ -n "$nix_shell_name" ]]; then |
|
|
14 |
echo " \e[0;36m(nix-shell)\e[0m" |
|
|
15 |
fi |
|
|
16 |
} |
|
|
17 |
|
|
|
18 |
# Better prompt. |
|
|
19 |
export PS1="[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]]$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ " |
|
|
20 |
|
|
|
21 |
# General aliases. |
|
|
22 |
alias ls='ls --color=none' |
|
|
23 |
alias l='ls -lh --color=none' |
|
|
24 |
alias ll='ls -lha --color=none' |
|
|
25 |
alias t='tree -L 2' |
|
|
26 |
alias ..='cd ..' |
|
|
27 |
alias grep='grep --color=always' |
|
|
28 |
alias less='less -R' |
|
|
29 |
alias tmux='tmux -u' |
|
|
30 |
alias vi='vim' |
|
|
31 |
alias server='python3 -m http.server 6969' |
|
|
32 |
|
|
|
33 |
# Custom folder jump commands. |
|
|
34 |
alias p='cd ~/Vault/projects' |
|
|
35 |
alias j='cd ~/Junk/current' |
|
|
36 |
alias d='cd ~/Downloads' |
|
|
37 |
|
|
|
38 |
# Additional path settings. |
|
|
39 |
export PATH=$HOME/Applications:$PATH |
|
|
40 |
export PATH=$HOME/go/bin:$PATH |
|
|
41 |
export PATH=/usr/local/go/bin:$PATH |
|
|
42 |
|
|
|
43 |
# History and search. Stolen from J. |
|
|
44 |
HISTCONTROL=ignoreboth |
|
|
45 |
shopt -s histappend |
|
|
46 |
export HISTSIZE= |
|
|
47 |
export HISTFILESIZE= |
|
|
48 |
export HISTFILE=~/.bash_history_infinite |
|
|
49 |
PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" |
|
|
50 |
bind '"\e[A": history-search-backward' |
|
|
51 |
bind '"\e[B": history-search-forward' |
|
|
52 |
export HSTR_CONFIG=hicolor |
|
|
53 |
if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi |
|
|
54 |
|
|
|
55 |
# Machine provision script for essential software. |
|
|
56 |
# This is meant to be used on Debian 11+. |
|
|
57 |
provision() { |
|
|
58 |
doas apt install \ |
|
|
59 |
build-essential git gcc make busybox cifs-utils tree hstr s3cmd \ |
|
|
60 |
xmlstarlet htop nvtop tmux picom scrot xclip mc ripgrep jq \ |
|
|
61 |
rsync doas newsboat entr clang clang-tidy clang-tools \ |
|
|
62 |
libx11-dev libxinerama-dev libxft-dev x11-xserver-utils \ |
|
|
63 |
stow podman podman-compose |
|
|
64 |
} |
|
|
65 |
|
|
|
66 |
# Backup to NAS function. Much wow! |
|
|
67 |
backup() { |
|
|
68 |
CWD=$(pwd) |
|
|
69 |
VHOME=/home/$USER/Vault |
|
|
70 |
ME=$(whoami)@$(hostname) |
|
|
71 |
|
|
|
72 |
mkdir -p $VHOME/dotfiles |
|
|
73 |
cd $VHOME/dotfiles |
|
|
74 |
|
|
|
75 |
# Make a copy of certain files. |
|
|
76 |
rsync -azhv /home/$USER/.bash_history_infinite bash_history_infinite |
|
|
77 |
rsync -azhv /home/$USER/.ssh/ ssh |
|
|
78 |
rsync -azhv /home/$USER/.aws/ aws |
|
|
79 |
rsync -azhv /home/$USER/.gnupg/ gnupg/ |
|
|
80 |
|
|
|
81 |
# Sync with NAS. |
|
|
82 |
rsync -azhvpog \ |
|
|
83 |
--exclude '.venv/' \ |
|
|
84 |
--exclude '.git/' \ |
|
|
85 |
--exclude '.import/' \ |
|
|
86 |
--exclude '.godot/' \ |
|
|
87 |
--exclude '.zig-cache/' \ |
|
|
88 |
--exclude 'node_modules/' \ |
|
|
89 |
--exclude 'digg-v5/' \ |
|
|
90 |
--delete \ |
|
|
91 |
$VHOME/ /media/Void/Backup/$ME/ |
|
|
92 |
|
|
|
93 |
# Add to log file. |
|
|
94 |
echo `date +"%D %T"` >> ~/.vault.log |
|
|
95 |
notify-send "Backup finished successfully." |
|
|
96 |
|
|
|
97 |
# Return back to original directory |
|
|
98 |
cd $CWD |
|
|
99 |
} |
|
|
100 |
|
|
|
101 |
# Simple ticket system based on https://github.com/mitjafelicijan/ticket. |
|
|
102 |
export TICKETS=~/Vault/tickets |
|
|
103 |
tt() { |
|
|
104 |
if [ "$(uname -s)" != "Linux" ]; then |
|
|
105 |
printf "Currently only Linux is supported.\n" |
|
|
106 |
return 1 |
|
|
107 |
fi |
|
|
108 |
|
|
|
109 |
if [ -z "$TICKETS" ]; then |
|
|
110 |
TICKETS="$HOME/tickets" |
|
|
111 |
fi |
|
|
112 |
|
|
|
113 |
mkdir -p $TICKETS |
|
|
114 |
|
|
|
115 |
# Display open tickets if no argument provided. |
|
|
116 |
if [ -z "$1" ]; then |
|
|
117 |
echo "`tt -o`" |
|
|
118 |
return 0 |
|
|
119 |
fi |
|
|
120 |
|
|
|
121 |
case $1 in |
|
|
122 |
-n|-new) |
|
|
123 |
# ticket_id=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1) |
|
|
124 |
ticket_id=$(echo -n "$(date)" | md5sum | cut -c 9-20) |
|
|
125 |
ticket_file=$TICKETS/$ticket_id |
|
|
126 |
printf "id: %s\n" $ticket_id > $ticket_file |
|
|
127 |
printf "responsible: %s\n" `whoami`@`hostname` >> $ticket_file |
|
|
128 |
printf "created: %s\n" "`date`" >> $ticket_file |
|
|
129 |
printf "status: open\n" >> $ticket_file |
|
|
130 |
printf "title: ?\n" >> $ticket_file |
|
|
131 |
printf "====\n" >> $ticket_file |
|
|
132 |
printf "Description...\n" >> $ticket_file |
|
|
133 |
$EDITOR $ticket_file |
|
|
134 |
;; |
|
|
135 |
-o|-open) |
|
|
136 |
printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title" |
|
|
137 |
printf "%0.s-" {1..100} |
|
|
138 |
printf "\n" |
|
|
139 |
grep --color=never -l 'status: open' $TICKETS/* | while read file; do |
|
|
140 |
id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }') |
|
|
141 |
title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
142 |
cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
143 |
cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") |
|
|
144 |
printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" |
|
|
145 |
done |
|
|
146 |
;; |
|
|
147 |
-c|-closed) |
|
|
148 |
printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title" |
|
|
149 |
printf "%0.s-" {1..100} |
|
|
150 |
printf "\n" |
|
|
151 |
grep --color=never -l 'status: closed' $TICKETS/* | while read file; do |
|
|
152 |
id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }') |
|
|
153 |
title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
154 |
cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
155 |
cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") |
|
|
156 |
printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" |
|
|
157 |
done |
|
|
158 |
;; |
|
|
159 |
-h|-help) |
|
|
160 |
printf "Usage: ticket [option]\n" |
|
|
161 |
printf " -n, -new creates a new ticket\n" |
|
|
162 |
printf " -o, -open lists open tickets\n" |
|
|
163 |
printf " -c, -closed lists closed tickets\n" |
|
|
164 |
printf " -h, -help shows this help\n" |
|
|
165 |
;; |
|
|
166 |
*) |
|
|
167 |
if [ -e "$TICKETS/$1" ] && [ -f "$TICKETS/$1" ]; then |
|
|
168 |
$EDITOR "$TICKETS/$1" |
|
|
169 |
else |
|
|
170 |
printf "Ticket not found: $TICKETS/$1\n" |
|
|
171 |
fi |
|
|
172 |
;; |
|
|
173 |
esac |
|
|
174 |
} |
|
|
175 |
|
|
|
176 |
# Toggles between pulseaudio sinks in round-robin. |
|
|
177 |
togglesink() { |
|
|
178 |
sinks=($(pactl list short sinks | awk '{print $2}')) |
|
|
179 |
current_sink=$(pactl get-default-sink) |
|
|
180 |
current_index=-1 |
|
|
181 |
|
|
|
182 |
for i in "${!sinks[@]}"; do |
|
|
183 |
if [[ "${sinks[$i]}" == "$current_sink" ]]; then |
|
|
184 |
current_index=$i |
|
|
185 |
break |
|
|
186 |
fi |
|
|
187 |
done |
|
|
188 |
|
|
|
189 |
if [[ $current_index -eq -1 ]]; then |
|
|
190 |
next_index=0 |
|
|
191 |
else |
|
|
192 |
next_index=$(( (current_index + 1) % ${#sinks[@]} )) |
|
|
193 |
fi |
|
|
194 |
|
|
|
195 |
pactl set-default-sink "${sinks[$next_index]}" |
|
|
196 |
notify-send "Switched to sink: ${sinks[$next_index]}" |
|
|
197 |
} |
|
|
198 |
|
|
diff --git a/rssfeeds b/rssfeeds
|
| 1 |
https://theorangeduck.com/feeds/pages |
|
|
| 2 |
https://lwn.net/headlines/rss |
|
|
| 3 |
https://kristoff.it/index.xml |
|
|
| 4 |
https://www.computerenhance.com/feed |
|
|
| 5 |
https://tratt.net/laurie/news.rss |
|
|
| 6 |
https://willhbr.net/feed.xml |
|
|
| 7 |
https://andrewkelley.me/rss.xml |
|
|
| 8 |
https://beyondloom.com/blog/rss.xml |
|
|
| 9 |
https://thomashunter.name/feed.rss |
|
|
| 10 |
https://decuser.github.io/feed.xml |
|
|
| 11 |
https://simonwillison.net/atom/entries/ |
|
|
| 12 |
https://til.simonwillison.net/tils/feed.atom |
|
|
| 13 |
https://www.andreinc.net/feed.xml |
|
|
| 14 |
https://voussoir.net/writing/writing.atom |
|
|
| 15 |
https://blog.regehr.org/feed |
|
|
| 16 |
https://richiejp.com/atom.xml |
|
|
| 17 |
https://szymonkaliski.com/feed.xml |
|
|
| 18 |
https://world.hey.com/dhh/feed.atom |
|
|
| 19 |
https://mitchellh.com/feed.xml |
|
|
| 20 |
https://matt-rickard.com/rss |
|
|
| 21 |
https://neil.computer/rss/ |
|
|
| 22 |
https://matduggan.com/rss/ |
|
|
| 23 |
https://michael.stapelberg.ch/feed.xml |
|
|
| 24 |
https://journal.valeriansaliou.name/rss/ |
|
|
| 25 |
https://www.duskborn.com/index.xml |
|
|
| 26 |
https://mirzapandzo.com/rss.xml |
|
|
| 27 |
https://mitjafelicijan.com/feed.xml |
|
|
| 28 |
https://crawl.develz.org/wordpress/feed |
|
|
| 29 |
https://go.dev/blog/feed.atom |
|
|
| 30 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCUSck1dOH7VKmG4lRW7tZXg |
|
|
| 31 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCkK9UDm_ZNrq_rIXCz3xCGA |
|
|
| 32 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCwgKmJM4ZJQRJ-U5NjvR2dg |
|
|
| 33 |
https://www.youtube.com/feeds/videos.xml?channel_id=UC8DntJ-sBtgC-jA0yEjxqjw |
|
|
| 34 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCrqM0Ym_NbK1fqeQG2VIohg |
|
|
| 35 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCUzQJ3JBuQ9w-po4TXRJHiA |
|
|
| 36 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCUyeluBRhGPCW4rPe_UvBZQ |
|
|
| 37 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCS0N5baNlQWJCUrhCEo8WlA |
|
|
| 38 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCsBjURrPoezykLs9EqgamOA |
|
|
| 39 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCaTznQhurW5AaiYPbhEA-KA |
|
|
| 40 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCld68syR8Wi-GY_n4CaoJGA |
|
|
| 41 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCXuqSBlHAE6Xw-yeJA0Tunw |
|
|
| 42 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCVk4b-svNJoeytrrlOixebQ |
|
|
| 43 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCNzszbnvQeFzObW0ghk0Ckw |
|
|
| 44 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCAMu6Dso0ENoNm3sKpQsy0g |
|
|
| 45 |
https://www.youtube.com/feeds/videos.xml?channel_id=UC2DjFE7Xf11URZqWBigcVOQ |
|
|
| 46 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCVls1GmFKf6WlTraIb_IaJg |
|
|
| 47 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCTAfm-YD2M9xzvbYvRc5ttA |
|
|
| 48 |
https://www.youtube.com/feeds/videos.xml?channel_id=UC5--wS0Ljbin1TjWQX6eafA |
|
|
| 49 |
https://www.youtube.com/feeds/videos.xml?channel_id=UCmtyQOKKmrMVaKuRXz02jbQ |
|
|
|
diff --git a/shenanigans.sh b/shenanigans.sh
|
| 1 |
# Magical environment variables. |
|
|
| 2 |
NIX_SHELL_PRESERVE_PROMPT=1 |
|
|
| 3 |
TERM=xterm-256color |
|
|
| 4 |
VISUAL=vim |
|
|
| 5 |
EDITOR=vim |
|
|
| 6 |
|
|
|
| 7 |
parse_git_branch() { |
|
|
| 8 |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' |
|
|
| 9 |
} |
|
|
| 10 |
|
|
|
| 11 |
is_inside_nix_shell() { |
|
|
| 12 |
nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)" |
|
|
| 13 |
if [[ -n "$nix_shell_name" ]]; then |
|
|
| 14 |
echo " \e[0;36m(nix-shell)\e[0m" |
|
|
| 15 |
fi |
|
|
| 16 |
} |
|
|
| 17 |
|
|
|
| 18 |
# Better prompt. |
|
|
| 19 |
export PS1="[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]]$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ " |
|
|
| 20 |
|
|
|
| 21 |
# General aliases. |
|
|
| 22 |
alias ls='ls --color=none' |
|
|
| 23 |
alias l='ls -lh --color=none' |
|
|
| 24 |
alias ll='ls -lha --color=none' |
|
|
| 25 |
alias t='tree -L 2' |
|
|
| 26 |
alias ..='cd ..' |
|
|
| 27 |
alias grep='grep --color=always' |
|
|
| 28 |
alias less='less -R' |
|
|
| 29 |
alias tmux='tmux -u' |
|
|
| 30 |
alias vi='vim' |
|
|
| 31 |
alias server='python3 -m http.server 6969' |
|
|
| 32 |
|
|
|
| 33 |
# Custom folder jump commands. |
|
|
| 34 |
alias p='cd ~/Vault/projects' |
|
|
| 35 |
alias j='cd ~/Junk/current' |
|
|
| 36 |
alias d='cd ~/Downloads' |
|
|
| 37 |
|
|
|
| 38 |
# Additional path settings. |
|
|
| 39 |
export PATH=$HOME/Applications:$PATH |
|
|
| 40 |
export PATH=$HOME/go/bin:$PATH |
|
|
| 41 |
export PATH=/usr/local/go/bin:$PATH |
|
|
| 42 |
|
|
|
| 43 |
# History and search. Stolen from J. |
|
|
| 44 |
HISTCONTROL=ignoreboth |
|
|
| 45 |
shopt -s histappend |
|
|
| 46 |
export HISTSIZE= |
|
|
| 47 |
export HISTFILESIZE= |
|
|
| 48 |
export HISTFILE=~/.bash_history_infinite |
|
|
| 49 |
PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" |
|
|
| 50 |
bind '"\e[A": history-search-backward' |
|
|
| 51 |
bind '"\e[B": history-search-forward' |
|
|
| 52 |
export HSTR_CONFIG=hicolor |
|
|
| 53 |
if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi |
|
|
| 54 |
|
|
|
| 55 |
# Machine provision script for essential software. |
|
|
| 56 |
# This is meant to be used on Debian 11+. |
|
|
| 57 |
provision() { |
|
|
| 58 |
doas apt install \ |
|
|
| 59 |
build-essential git gcc make busybox cifs-utils tree hstr s3cmd \ |
|
|
| 60 |
xmlstarlet htop nvtop tmux picom scrot xclip mc ripgrep jq \ |
|
|
| 61 |
rsync doas newsboat entr clang clang-tidy clang-tools \ |
|
|
| 62 |
libx11-dev libxinerama-dev libxft-dev x11-xserver-utils \ |
|
|
| 63 |
podman podman-compose |
|
|
| 64 |
} |
|
|
| 65 |
|
|
|
| 66 |
# Backup to NAS function. Much wow! |
|
|
| 67 |
backup() { |
|
|
| 68 |
CWD=$(pwd) |
|
|
| 69 |
VHOME=/home/$USER/Vault |
|
|
| 70 |
ME=$(whoami)@$(hostname) |
|
|
| 71 |
|
|
|
| 72 |
mkdir -p $VHOME/dotfiles |
|
|
| 73 |
cd $VHOME/dotfiles |
|
|
| 74 |
|
|
|
| 75 |
# Make a copy of certain files. |
|
|
| 76 |
rsync -azhv /home/$USER/.bash_history_infinite bash_history_infinite |
|
|
| 77 |
rsync -azhv /home/$USER/.ssh/ ssh |
|
|
| 78 |
rsync -azhv /home/$USER/.aws/ aws |
|
|
| 79 |
rsync -azhv /home/$USER/.gnupg/ gnupg/ |
|
|
| 80 |
|
|
|
| 81 |
# Sync with NAS. |
|
|
| 82 |
rsync -azhvpog \ |
|
|
| 83 |
--exclude '.venv/' \ |
|
|
| 84 |
--exclude '.git/' \ |
|
|
| 85 |
--exclude '.import/' \ |
|
|
| 86 |
--exclude '.godot/' \ |
|
|
| 87 |
--exclude '.zig-cache/' \ |
|
|
| 88 |
--exclude 'node_modules/' \ |
|
|
| 89 |
--exclude 'digg-v5/' \ |
|
|
| 90 |
--delete \ |
|
|
| 91 |
$VHOME/ /media/Void/Backup/$ME/ |
|
|
| 92 |
|
|
|
| 93 |
# Add to log file. |
|
|
| 94 |
echo `date +"%D %T"` >> ~/.vault.log |
|
|
| 95 |
notify-send "Backup finished successfully." |
|
|
| 96 |
|
|
|
| 97 |
# Return back to original directory |
|
|
| 98 |
cd $CWD |
|
|
| 99 |
} |
|
|
| 100 |
|
|
|
| 101 |
# Simple ticket system based on https://github.com/mitjafelicijan/ticket. |
|
|
| 102 |
export TICKETS=~/Vault/tickets |
|
|
| 103 |
tt() { |
|
|
| 104 |
if [ "$(uname -s)" != "Linux" ]; then |
|
|
| 105 |
printf "Currently only Linux is supported.\n" |
|
|
| 106 |
return 1 |
|
|
| 107 |
fi |
|
|
| 108 |
|
|
|
| 109 |
if [ -z "$TICKETS" ]; then |
|
|
| 110 |
TICKETS="$HOME/tickets" |
|
|
| 111 |
fi |
|
|
| 112 |
|
|
|
| 113 |
mkdir -p $TICKETS |
|
|
| 114 |
|
|
|
| 115 |
# Display open tickets if no argument provided. |
|
|
| 116 |
if [ -z "$1" ]; then |
|
|
| 117 |
echo "`tt -o`" |
|
|
| 118 |
return 0 |
|
|
| 119 |
fi |
|
|
| 120 |
|
|
|
| 121 |
case $1 in |
|
|
| 122 |
-n|-new) |
|
|
| 123 |
# ticket_id=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1) |
|
|
| 124 |
ticket_id=$(echo -n "$(date)" | md5sum | cut -c 9-20) |
|
|
| 125 |
ticket_file=$TICKETS/$ticket_id |
|
|
| 126 |
printf "id: %s\n" $ticket_id > $ticket_file |
|
|
| 127 |
printf "responsible: %s\n" `whoami`@`hostname` >> $ticket_file |
|
|
| 128 |
printf "created: %s\n" "`date`" >> $ticket_file |
|
|
| 129 |
printf "status: open\n" >> $ticket_file |
|
|
| 130 |
printf "title: ?\n" >> $ticket_file |
|
|
| 131 |
printf "====\n" >> $ticket_file |
|
|
| 132 |
printf "Description...\n" >> $ticket_file |
|
|
| 133 |
$EDITOR $ticket_file |
|
|
| 134 |
;; |
|
|
| 135 |
-o|-open) |
|
|
| 136 |
printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title" |
|
|
| 137 |
printf "%0.s-" {1..100} |
|
|
| 138 |
printf "\n" |
|
|
| 139 |
grep --color=never -l 'status: open' $TICKETS/* | while read file; do |
|
|
| 140 |
id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }') |
|
|
| 141 |
title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
| 142 |
cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
| 143 |
cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") |
|
|
| 144 |
printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" |
|
|
| 145 |
done |
|
|
| 146 |
;; |
|
|
| 147 |
-c|-closed) |
|
|
| 148 |
printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title" |
|
|
| 149 |
printf "%0.s-" {1..100} |
|
|
| 150 |
printf "\n" |
|
|
| 151 |
grep --color=never -l 'status: closed' $TICKETS/* | while read file; do |
|
|
| 152 |
id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }') |
|
|
| 153 |
title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
| 154 |
cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
|
|
| 155 |
cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") |
|
|
| 156 |
printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" |
|
|
| 157 |
done |
|
|
| 158 |
;; |
|
|
| 159 |
-h|-help) |
|
|
| 160 |
printf "Usage: ticket [option]\n" |
|
|
| 161 |
printf " -n, -new creates a new ticket\n" |
|
|
| 162 |
printf " -o, -open lists open tickets\n" |
|
|
| 163 |
printf " -c, -closed lists closed tickets\n" |
|
|
| 164 |
printf " -h, -help shows this help\n" |
|
|
| 165 |
;; |
|
|
| 166 |
*) |
|
|
| 167 |
if [ -e "$TICKETS/$1" ] && [ -f "$TICKETS/$1" ]; then |
|
|
| 168 |
$EDITOR "$TICKETS/$1" |
|
|
| 169 |
else |
|
|
| 170 |
printf "Ticket not found: $TICKETS/$1\n" |
|
|
| 171 |
fi |
|
|
| 172 |
;; |
|
|
| 173 |
esac |
|
|
| 174 |
} |
|
|
| 175 |
|
|
|
| 176 |
# Toggles between pulseaudio sinks in round-robin. |
|
|
| 177 |
togglesink() { |
|
|
| 178 |
sinks=($(pactl list short sinks | awk '{print $2}')) |
|
|
| 179 |
current_sink=$(pactl get-default-sink) |
|
|
| 180 |
current_index=-1 |
|
|
| 181 |
|
|
|
| 182 |
for i in "${!sinks[@]}"; do |
|
|
| 183 |
if [[ "${sinks[$i]}" == "$current_sink" ]]; then |
|
|
| 184 |
current_index=$i |
|
|
| 185 |
break |
|
|
| 186 |
fi |
|
|
| 187 |
done |
|
|
| 188 |
|
|
|
| 189 |
if [[ $current_index -eq -1 ]]; then |
|
|
| 190 |
next_index=0 |
|
|
| 191 |
else |
|
|
| 192 |
next_index=$(( (current_index + 1) % ${#sinks[@]} )) |
|
|
| 193 |
fi |
|
|
| 194 |
|
|
|
| 195 |
pactl set-default-sink "${sinks[$next_index]}" |
|
|
| 196 |
notify-send "Switched to sink: ${sinks[$next_index]}" |
|
|
| 197 |
} |
|
|
| 198 |
|
|
|