Compare commits

..

2 Commits

Author SHA1 Message Date
Anton Lydike 600603be3c readme update 4 years ago
Anton Lydike ff45f031bf whiteout config update 4 years ago

@ -1,6 +1,6 @@
# Dotfiles
My dotfiles repository
My dotfiles repository for machine `whiteout`
## Contents

@ -0,0 +1,12 @@
#!/usr/bin/env fish
if test "$argv[1]" = "-w"
set time $argv[2]
test -z "$time" && set time 1
while true
echo (cpu-temp)
sleep $time
end
else
sensors -j | jq '."k10temp-pci-00c3".Tdie.temp1_input'
end

@ -0,0 +1,28 @@
#!/usr/bin/env fish
set watermark watermark.tex
set preface preface.pdf
function gen_watermark
set -l id (random)
cat "$watermark" | string replace -a "{{person}}" "$argv[1]" > "$id.tex"
pdflatex "$id.tex" > /dev/null
pdflatex "$id.tex" > /dev/null #run twice for transparency
# remove log and aux file
rm $id.aux $id.log $id.tex
echo "$id.pdf"
end
function assemble
set -l id (random)
set watermark_file (gen_watermark $argv)
echo pdftk "$argv[2]" stamp "$watermark_file" output "$id.pdf"
pdftk "$argv[2]" stamp "$watermark_file" output "$id.pdf"
pdftk "$preface" "$id.pdf" output "$id"-marked.pdf
# clean up files
rm "$watermark_file"
rm "$id.pdf"
echo "$id"-marked.pdf
end
assemble $argv

@ -0,0 +1,40 @@
#!/usr/bin/env fish
set countrycode 'de'
set lang 'en-US'
set limit 1
set q "$argv[1]"
set raw 'false'
set jqstr '.lat, .lon, .display_name'
# if run in a terminal, one line per output
if test -t 1
set jqstr '"\(.lat) \(.lon) \(.display_name)"'
set limit 5
end
set i 1
while test $i -le (count $argv)
switch $argv[$i]
case '-n'
set i (math $i + 1)
set limit $argv[$i]
case '-c'
set i (math $i + 1)
set countrycode $argv[$i]
case '-r'
set raw 'true'
case '*'
set q $p $argv[$i]
end
set i (math $i + 1)
end
set result (curl -s "https://nominatim.openstreetmap.org/search?q=$q&format=json&limit=$limit&countrycodes=$countrycode&accept-language=$lang")
if test "$raw" = 'true'
echo $result | python -m json.tool
else
echo $result | jq -r ".[] | $jqstr"
end

@ -0,0 +1 @@
/home/anton/projects/graphing/graphing-nix.sh

@ -0,0 +1,21 @@
#!/usr/bin/env fish
# syntax: moov files... regex target
set regex $argv[-2]
set target $argv[-1]
set files $argv[1..-3]
for file in $files
set matches (string match -ar "$regex" "$file")
set target_path "$target"
set counter 0
for match in $matches
set target_path (string replace -a '$'"$counter" "$match" "$target_path")
set counter (math $counter + 1)
end
mv "$file" "$target_path"
end

@ -26,17 +26,26 @@
import sys
import json
import math
import subprocess
from os import listdir
from os.path import isfile, join
green = '#00FF00'
red = '#FF0000'
def get_inbox_items():
path = "/home/anton/inbox"
files = listdir(path)
files = list(filter(lambda p: p[0] != '.', listdir(path)))
if not files:
return bar_entry('∅', 'inbox', '#00FF00')
return bar_entry('∅', 'inbox', green)
files.sort()
return bar_entry("inbox: " + ", ".join(files), 'inbox', '#FF0000')
return bar_entry("inbox: " + ", ".join(files), 'inbox', red)
def get_cpu_temp():
temp = subprocess.check_output(['bash', '-c', 'sensors -j | jq \'."k10temp-pci-00c3".Tdie.temp1_input\'']).decode().strip()
temp = math.floor(float(temp))
return bar_entry(str(temp) + "°C", 'temp', green if temp < 75 else red)
def bar_entry(content, name, color = '#000000'):
return {'full_text' : content, 'name' : name, 'color': color}
@ -76,6 +85,7 @@ if __name__ == '__main__':
# insert information into the start of the json, but could be anywhere
# CHANGE THIS LINE TO INSERT SOMETHING ELSE
j.insert(0, get_inbox_items())
j.insert(4, get_cpu_temp())
# and echo back new encoded json
print_line(prefix+json.dumps(j))

@ -0,0 +1,14 @@
#!/usr/bin/env fish
set lat $argv[1]
set lon $argv[2]
set token '9755405ea54edcefb75bcc61cc9c3c60'
#if test ! -z $argv[3]
# set_color green
# echo "Weather at $argv[3]"
# set_color normal
#end
#curl -s "https://api.openweathermap.org/data/2.5/forecast?lat=$lat&lon=$lon&appid=$token" | jq -r '.list[] | "\(.dt_txt[0:16]) \(.weather[0].description) at \(.main.temp - 273.15|round)°C"'
curl -s "https://api.openweathermap.org/data/2.5/forecast?lat=$lat&lon=$lon&appid=$token" | jq -r '.list[] | .main.temp - 273.15|round'

@ -1,8 +1,14 @@
# Defined in /tmp/fish.soaTnu/fish_greeting.fish @ line 2
function fish_greeting
if test "$TERM_PROGRAM" = vscode
return
end
if set -q fish_private_mode
return
end
set greetings "Hello there" (echo -ne "Aye aye, "; set_color -o; echo -ne "captain"; set_color normal) \
"Welcome back, Commander Shepard" "Waiting for orders!"
@ -14,6 +20,6 @@ function fish_greeting
set_color red
echo -e "\tInbox not empty!"
set_color normal
ls -1 --quoting-style=literal inbox/ | string join ", "
ls -1 --quoting-style=literal ~/inbox/ | string join ", "
end
end

@ -1,4 +1,4 @@
# Defined in /home/anton/.config/fish/functions/fish_prompt.fish @ line 1
# Defined in /tmp/fish.N4kwkU/fish_prompt.fish @ line 2
function fish_prompt
set -l git_branch (git branch ^/dev/null | sed -n '/\* /s///p')
@ -8,9 +8,17 @@ function fish_prompt
set git_branch ""
end
if set -q fish_private_mode
echo -n "🕶 "
end
if test -n "$IN_NIX_SHELL"
set_color cyan
echo -n "nix "
if test "$name" != "shell"
echo -n "$name "
else
echo -n "nix "
end
set_color normal
end

@ -0,0 +1,4 @@
# Defined in /run/user/1000/fish.iwIwIq/la.fish @ line 2
function la --description 'List contents of directory, including hidden files in directory using long format'
ls -lahF $argv
end

@ -1,4 +1,4 @@
# Defined in - @ line 1
function ll --description 'alias ll=ls -AlFh'
ls -AlFh $argv;
# Defined in /tmp/fish.Ryo4Qd/ll.fish @ line 2
function ll --description 'alias ll ls -l'
ls -lhF $argv;
end

@ -1,4 +1,39 @@
# Defined in /tmp/fish.dwCY0N/mount-vc.fish @ line 2
# Defined in /tmp/fish.vUSaaU/mount-vc.fish @ line 2
function mount-vc --argument device key_name target -d Mount a veracrypt container with a keyfile stored in /home/anton/.keys
nix-shell -p veracrypt --run "sudo veracrypt -k /home/anton/.keys/$argv[2] -p \"\" $argv[1] $argv[3]"
if test -z "$argv[1]" -o \( "$argv[1]" = "--help" \) -o \( "$argv[1]" = "-h" \)
echo -e "mount-vc: Mount or dismount veracrypt volumes\n\
\n\
Usage:\n\
mount a volume using a keyfile:\n\
\n\
mount-vc <device> <key file name> <target>\n\
\n\
mount a volume using a password: (will be prompted for)\n\
\n\
mount-vc <device> <target>\n\
\n\
dismount a volume:\n\
\n\
mount-vc -d <target>\n"
return
end
if test "$argv[1]" = "-d"
sudo veracrypt -d "argv[2]"
return
end
set dev "$argv[1]"
set target "$argv[3]"
set opts "-t" "--non-interactive"
if test (count $argv) = 2
read -s -P "Volume password: " pass
set target "$argv[2]"
set -a opts "--password=$pass"
else
set -a opts "-k" "/home/anton/.keys/$argv[2]" "-p" ""
end
sudo veracrypt $opts "$dev" "$target"
end

@ -0,0 +1,22 @@
# Defined in /home/anton/.config/fish/functions/mwatch.fish @ line 2
function mwatch
argparse --name=mwatch -s 'n=' -- $argv
or return 1
set n "$_flag_n"
test -z "$n" -o "$n" -le 0; and set n 2
while true
set output (eval $argv)
clear
echo (date)" - refreshing every $n seconds"
for line in $output
echo $line
end
sleep "$n"
end
end

@ -1,3 +1,3 @@
function telegram
nix-shell -p tdesktop --run "telegram-desktop >/dev/null 2>&1 & disown"
telegram-desktop >/dev/null 2>&1 & disown
end

@ -0,0 +1,53 @@
# Defined in /tmp/fish.iOyNXX/todo.fish @ line 2
function todo
argparse --name=todo 'n/next' 't/today' 's/show' 'r/rotate' 'd/done=' -- $argv
or return 1
test -n "$_flag_n"; and set -l day 'next'
test -n "$_flag_t"; and set -l day 'today'
test -z "$day" -a -n "$_flag_s"; and set -l day 'today'
test -z "$day" -a -n "$_flag_d"; and set -l day 'today'
test -z "$day"; and set -l day 'next'
set day_print "$day"
test "$day" = "next"; and set day_print "tomorrow" # rename next to tomorrow when printing
set file ~/todo/"$day".md
if test -n "$_flag_s"
test ! -e "$file"; and echo "Nothing todo $day_print"; and return 0
echo -e "# TODO $day_print\n" | bat --color always -l markdown -p - "$file"
else if test -n "$_flag_r"
# if no todos are due for tomorrow, return
test ! -e ~/todo/next.md;and echo "Nothing todo tomorrow"; and return 0
cat ~/todo/next.md >> ~/todo/today.md
rm ~/todo/next.md
else if test -n "$_flag_d"
# the number to remove is first arg
set num "$_flag_d"
set num (math "1 + ($num - 1) * 2")
set todos (cat "$file")
set elem $todos[$num]
# remove fields in array
set -e todos[$num]
set -e todos[$num]
# join elements by newlines. This creates a leading newline
# which is then ignored by using tail with the count of elements
# in the todos array
echo -e \n$todos | tail -(count $todos) > "$file"
echo "\"$elem\" is no longer on the list for $day_print"
else
echo -e "* $argv\n" >> $file
echo "Added todo for $day_print: \"$argv\""
end
end

@ -0,0 +1,4 @@
# Defined in - @ line 1
function todos --description 'alias todos=todo -s'
todo -s $argv;
end

@ -0,0 +1,37 @@
#!/usr/bin/env fish
set whitelist inbox pics docs music movies
set blacklist Desktop Downloads/Telegram\ Desktop Downloads Documents
set inbox inbox
# make sure whitelisted items exist
set_color green
for folder in $whitelist
test ! -d ~/"$folder"
and mkdir -p ~/"$folder"
and echo " * created ~/$folder"
or echo " * skipping ~/$folder"
# echo "==="
end
# move blacklisted items into inbox, delete folders
set_color red
for folder in $blacklist
test -d ~/"$folder"
and cp -r ~/"$folder"/. ~/"$inbox"
and rm -r ~/"$folder"
and echo " * removed ~/$folder"
or echo " * skipping ~/$folder"
#echo "==="
end

@ -201,10 +201,10 @@ bar {
set $mode_sys System (l)ock (h)ibernate log(o)ut (Shift+s)hutdown (r)eboot
mode "$mode_sys" {
bindsym l exec --no-startup-id i3lock -i pics/nix-blue-small.png, mode "default"
bindsym l exec --no-startup-id i3lock -t -f -i .lockscreen-image, mode "default"
bindsym r exec --no-startup-id reboot, mode "default"
bindsym o exec --no-startup-id i3-msg exit, mode "default"
bindsym h exec --no-startup-id i3lock -i Pictures/nix-dark-small.png && systemctl hibernate, mode "default"
#bindsym h exec --no-startup-id i3lock -i Pictures/nix-dark-small.png && systemctl hibernate, mode "default"
bindsym Shift+s exec --no-startup-id shutdown now, mode "default"
bindsym Return mode "default"

@ -11,29 +11,17 @@ general {
interval = 1
}
#order += "ipv6"
order += "wireless _first_"
order += "ethernet _first_"
order += "battery all"
order += "disk /"
order += "load"
order += "memory"
order += "tztime local"
wireless _first_ {
format_up = "W: (%quality at %essid) %ip"
format_down = "W: -"
}
ethernet _first_ {
format_up = "E: %ip (%speed)"
format_down = "E: -"
}
battery all {
format = "%status %percentage (%remaining at %consumption)"
}
disk "/" {
format = "%avail"
}
@ -49,5 +37,5 @@ memory {
}
tztime local {
format = "%Y-%m-%d %H:%M:%S"
format = "%Y-%m-%d W%V %H:%M:%S"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

@ -3,4 +3,5 @@ i3 /home/anton/.config/i3
i3status /home/anton/.config/i3status
termite /home/anton/.config/termite
fish /home/anton/.config/fish
nixos /etc/nixos
wallpaper.png /home/anton/.background-image
lockscreen.png /home/anton/.lockscreen-image

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Loading…
Cancel
Save