initial commit

master
Anton Lydike 5 years ago
commit 0ac22ca91e

@ -0,0 +1 @@
/home/anton/.bin

@ -0,0 +1,83 @@
#!/usr/bin/env fish
# listen to battery state and warn on low battery
# read low battery state level from environment and fallback to a value of 8
set LOW 8
test -n "$BAT_CRITICAL_LEVEL" -a "$BAT_CRITICAL_LEVEL" -gt 0; and set LOW "$BAT_CRITICAL_LEVEL"
# read config from environment
set ALARM_TEMP 1000
test -z "$BAT_ALARM_TEMP" -a "$BAT_ALARM_TEMP" -gt 1000; and set ALARM_TEMP "$BAT_ALARM_TEMP"
# if we are currently below or above our LOW threshold
set isLow "false"
# print config
echo "Set up with LOW=$LOW and ALARM_TEMP=$ALARM_TEMP"
#echo "redshift="(which redshift)
function check_btry
set state (upower -i /org/freedesktop/UPower/devices/battery_BAT0 | rg "(percent|state)" | awk -F " " '{print $2}')
set charge (echo "$state[2]" | string replace "%" "")
set state "$state[1]"
set c_low (test "$charge" -lt "$LOW"; and echo true; or echo false)
if test $c_low = true; and test $state = discharging; and test $isLow != true
echo "transitioning to low battery state"
low_btry_action
set isLow true
else if test ! $state = discharging; and test $isLow != false
echo "transtioning to high bat state (charger)"
set isLow false
high_btry_action
else if test $c_low = false; and test $isLow != false
echo "transitioning to high bat state (magic)"
set isLow false
high_btry_action
end
end
function low_btry_action
# kill redshift job and set fixed alarm temp
if jobs -q
echo killing redshift with pid (jobs -p)
kill (jobs -p)
end
redshift -P -O "$ALARM_TEMP"
end
function high_btry_action
# start redshift again
redshift -P -l 50.11552:8.68417 -t 5500:2500 &
end
if test "$argv[1]" = once
check_btry
set state (upower -i /org/freedesktop/UPower/devices/battery_BAT0 | rg "(percent|state)" | awk -F " " '{print $2}')
set charge (echo "$state[2]" | string replace "%" "")
set state "$state[1]"
echo "$charge : $state"
else
#set percent (upower -i /org/freedesktop/UPower/devices/battery_BAT0 | rg "(percent)" | awk -F " " '{print $2}' | string replace "%" "")
# set initial isLow variable to the opposite of what it's supposed to be to trigger a
#test "$percent" -lt "$LOW"; and set isLow "false"
set isLow unknown
sleep 5
while true
check_btry
sleep (test $isLow = true; and echo 1; or echo 60)
end
end

@ -0,0 +1,54 @@
#!/usr/bin/env python3
import sys, os
# config:
# put your device here
device="/sys/class/backlight/amdgpu_bl0/"
def smart_int(num):
if (num[0] == '+'): return int(num[1:])
return int(num)
def do_action(action):
if (action == 'show'):
curr = get_current()
_max = get_max()
print('screen brightness is at %s (%d/%d)' % (str(int(curr / _max * 100)), curr, _max));
return
if (action[-1:] == '%'):
if (action[0] == "+" or action[0] == '-'):
curr = get_current()
max = get_max()
curr_pc = curr / max * 100
put_brightness(int(max * ((curr_pc + smart_int(action[:-1])) / 100)))
else:
put_brightness(int(get_max() * (int(action[:-1]) / 100)))
elif (action[0] == '+' or action[0] == "-"):
put_brightness(get_current() + smart_int(action))
elif (action.isdigit()):
put_brightness(int(action))
def get_current():
with open(device + 'brightness', 'r') as f:
return int(f.read().replace('\n', ''))
def put_brightness(ammount):
ammount = num_in_range(ammount)
print("screen brightnes is " + str(ammount));
with open(device + 'brightness', 'r+') as f:
f.write(str(ammount))
def get_max():
with open(device + 'max_brightness', 'r') as f:
return int(f.read().replace('\n', ''))
def num_in_range(num):
max = get_max()
if (num > max): num = max
if (num < 0): num = 0
return num
for action in sys.argv[1::]: do_action(action)

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

1111
bin/fff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,34 @@
#!/bin/bash
set -eu
remote="git.pi"
cmd=${1:-""}
if [ "$cmd" == "init" ]; then
name="$2"
if [ ! -d "$name" ]; then
mkdir $name
fi;
cd $name
ssh git@git.pi "./create-repo.sh $name"
if [ ! -d ".git" ]; then
git init
fi;
git remote add local "git@$remote:$name.git"
elif [ "$cmd" == "clone" ]; then
name="$2"
git clone "git@$remote:$name.git" $name
else
echo "usage: gitlocal (init|clone) repository
remote: $remote
init: initialize repository on the remote server, then create a local folder linked to the remote
clone: clone a git repository from the remote";
fi;

@ -0,0 +1,31 @@
#!/usr/bin/env fish
set_color cyan
echo -e " sMMd\ \MMMN\ /hMMs \n\
\MMMm\ \NMMMY.mMMM/ \n\
\MMMN\ \mMMMNMMM/ \n\
/dmmmmNMMMMmmmmmhdMMMMN/ ¸¸ \n\
/MMMMMMMMMMMMMMMMMdhMMMd\ /NM/ \n\
``````-hddd/````````\MMMm\ /MMMm/ \n\
/NMMM/ \NMMdsMMMd/ \n\
,,,,,,,,/MMMM/ \NddMMMNo\,,,,\n\
hMMMMMMMMMMm| |mMMMMMMMMMMh\n\
`````oNMMMdhN\ /NMMM/´´´´´´´´\n\
/dMMMyhMMM\ /MMMN/ \n\
/mMMM/ \mMMMo,,,,,,,,/dddd-,,,,,¸ \n\
\MNM/ \dMMMhdMMMMMMMMMMMMMMMMM/ \n\
´´ /NMMMMdhmmmmmMMMMNmmmmd/ \n\
/NMMN:MMMm\ \NMMM\ \n\
/MMMm/\MMMN\ \mMMM\ \n\
sMMd/ \NMMM\ \dMMs "
#
# \#\ \#\/#/
# ############
# /#/ \#\/#/
###### ######
#/#/\#\ /#/
# #############
# /#/\#\ \#\

@ -0,0 +1,110 @@
#!/usr/bin/env fish
# get file name from path
function fname
string replace -r "^"(dirname "$argv[1]")/ "" "$argv[1]"
end
# convert a note name or otherwise stuff to a notes path
function n_path
if string match -qr "^"(realpath ~/notes) "$argv[1]"
echo $argv[1]
end
echo (realpath ~/notes)/(string replace -ar "\s" "_" "$argv[1]")
end
# ensure .md ending
function ensure_md
if test (count $argv) -eq 0 -a -t 0
read inp
else
set inp "$argv[1]"
end
if string match -qr "\.md\$" "$inp"
echo "$inp"
else
echo "$inp.md"
end
end
# edit a note, arg1 = note name
function note_edit
eval $EDITOR (n_path "$argv[1]" | ensure_md)
end
# create a new note
# agr1 = note name (path)
# arg2 = (opt) note content
function note_new
set path (n_path "$argv[1]" | ensure_md)
if test -f "$path"
echo "note at $path already exists"
exit 1
end
# create path for note
mkdir -p (dirname "$path")
echo -e "# "(fname "$argv[1]")"\n\n$argv[2]" > $path
note_edit "$path"
end
# show a note
# arg1 = path to note (or folder)
# arg2 = delimiter (default=", "
function note_search
set root (realpath ~/notes)/
set results
set delim ", "
test -n "$argv[2]"; and set delim "$argv[2]"
for f in (rg -l "$argv[1]" ~/notes)
set f (string replace "$root" "" "$f")
set results "$f" $results
end
echo -e (string join "$delim" $results)
end
# print the contents of a note
# arg1 = desired note path
function note_print
set path (n_path "$argv[1]" | ensure_md)
if test ! -f (n_path "$path")
echo "note at $path is not a file!"
exit 1
end
cat "$path"
end
# main
if test "$argv[1]" = "create"
note_new $argv[2..-1]
else if test "$argv[1]" = "edit"
note_edit $argv[2..-1]
else if test "$argv[1]" = "find" -o "$argv[1]" = "search"
note_search $argv[2..-1]
else if test "$argv[1]" = "git"
eval git -C ~/notes/ $argv[2..-1]
else if test "$argv[1]" = "print" -o "$argv[1]" = "show"
note_print $argv[2..-1]
else if test "$argv[1]" = "list" -o "$argv[1]" = "tree"
tree ~/notes/
else
echo "Unknown argument: $argv[1]"
end

@ -0,0 +1,60 @@
#!/usr/bin/env bash
# grab parameters, trim whitespaces
length="${*// }";
# look for easy mode "-e"
if [[ "$length" =~ ^-e$ ]]; then
passw=$(cat /dev/urandom | tr -cd 'a-z0-9' | head -c 32);
echo $passw | tr -d '\n' | xclip -selection c;
echo $passw
exit 0
elif [[ "$length" =~ ^-e=([0-9]+)$ ]]; then
# get length from regex
len=${BASH_REMATCH[1]};
passw=$(cat /dev/urandom | tr -cd 'a-z0-9' | head -c "$len");
echo $passw | tr -d '\n' | xclip -selection c;
echo $passw
exit 0
# look for -b=bytes
elif [[ "$length" =~ ^-b=([0-9]+)$ ]]; then
# set bytes
bytes=${BASH_REMATCH[1]};
# set length
let length=4*bytes/3+1;
# instead of ceiling the function, we just floor it and add 1, because the output length was specified in bytes
else
if [[ -z "$length" ]]; then
# if no parameters were given, the default is used
length=32
bytes=24
else
if ! [[ "$length" =~ ^[0-9]+$ ]]; then
echo -e "\e[91mError: '$length' is not a number!\e[0m";
exit 100;
fi
# calculate the bytes from the length
let bytes=30*length/4;
# ceil the result using python
bytes=$(python -c "from math import ceil; print ceil($bytes/10.0)" | tr -d '.0');
fi
fi
# generate the password
password=$(dd if=/dev/urandom bs=1 count="$bytes" 2>/dev/null | base64);
# idk why but they keep adding a newline after every 76th character, compensate for that!
let length=length+length/77;
# cut it and echo it
echo "${password:0:$length}" | tr -d '\n';
# we removed the newlines from the middle of the password adn from the end, add the one at the end back
echo "";
# copy the password to clipboard
echo "${password:0:$length}" | tr -d '\n' | xclip -selection c;
exit 0;

@ -0,0 +1,81 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This script is a simple wrapper which prefixes each i3status line with custom
# information. It is a python reimplementation of:
# http://code.stapelberg.de/git/i3status/tree/contrib/wrapper.pl
#
# To use it, ensure your ~/.i3status.conf contains this line:
# output_format = "i3bar"
# in the 'general' section.
# Then, in your ~/.i3/config, use:
# status_command i3status | ~/i3status/contrib/wrapper.py
# In the 'bar' section.
#
# In its current version it will display the cpu frequency governor, but you
# are free to change it to display whatever you like, see the comment in the
# source code below.
#
# © 2012 Valentin Haenel <valentin.haenel@gmx.de>
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law. You can redistribute it and/or modify it under
# the terms of the Do What The Fuck You Want To Public License (WTFPL), Version
# 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more
# details.
import sys
import json
from os import listdir
from os.path import isfile, join
def get_inbox_items():
path = "/home/anton/inbox"
files = listdir(path)
if not files:
return bar_entry('∅', 'inbox', '#00FF00')
files.sort()
return bar_entry("inbox: " + ", ".join(files), 'inbox', '#FF0000')
def bar_entry(content, name, color = '#000000'):
return {'full_text' : content, 'name' : name, 'color': color}
def print_line(message):
""" Non-buffered printing to stdout. """
sys.stdout.write(message + '\n')
sys.stdout.flush()
def read_line():
""" Interrupted respecting reader for stdin. """
# try reading a line, removing any extra whitespace
try:
line = sys.stdin.readline().strip()
# i3status sends EOF, or an empty line
if not line:
sys.exit(3)
return line
# exit on ctrl-c
except KeyboardInterrupt:
sys.exit()
if __name__ == '__main__':
# Skip the first line which contains the version header.
print_line(read_line())
# The second line contains the start of the infinite array.
print_line(read_line())
while True:
line, prefix = read_line(), ''
# ignore comma at start of lines
if line.startswith(','):
line, prefix = line[1:], ','
j = json.loads(line)
# 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())
# and echo back new encoded json
print_line(prefix+json.dumps(j))

@ -0,0 +1,23 @@
alias wificonnect='nmcli connection up'
alias nix-shell='nix-shell --command fish'
set PATH ~/.bin $PATH
if test "$TERMINAL" = 'termite'
set TERM xterm-color
end
function on_exit --on-event fish_exit
if test (status -f) = 'Standard input';
set byebyes "bravo six, going dark" "bye bye" "ight, imma head out" "see ya!" "I'LL BE BACK" "my job here is done"
echo $byebyes[(random 1 (count $byebyes))]
end
end
function random_iasip
set folge (find "/home/anton/movies/IASIP S1-10/" -iname "*.mkv" | shuf -n 1)
env VLC_VERBOSE=0 vlc "$folge" 2> /dev/null
end

@ -0,0 +1,31 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_init_2_39_8:\x1d
SETUVAR __fish_init_2_3_0:\x1d
SETUVAR fish_color_autosuggestion:555\x1ebrblack
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:\x2d\x2dbold
SETUVAR fish_color_comment:red
SETUVAR fish_color_cwd:green
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:brmagenta
SETUVAR fish_color_error:brred
SETUVAR fish_color_escape:bryellow\x1e\x2d\x2dbold
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:bryellow
SETUVAR fish_color_param:cyan
SETUVAR fish_color_quote:yellow
SETUVAR fish_color_redirection:brblue
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_completion:\x1d
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan

@ -0,0 +1,31 @@
# This file is automatically generated by the fish.
# Do NOT edit it directly, your changes will be overwritten.
SET __fish_init_2_39_8:\x1d
SET __fish_init_2_3_0:\x1d
SET fish_color_autosuggestion:555\x1ebrblack
SET fish_color_cancel:\x2dr
SET fish_color_command:\x2d\x2dbold
SET fish_color_comment:red
SET fish_color_cwd:green
SET fish_color_cwd_root:red
SET fish_color_end:brmagenta
SET fish_color_error:brred
SET fish_color_escape:bryellow\x1e\x2d\x2dbold
SET fish_color_history_current:\x2d\x2dbold
SET fish_color_host:normal
SET fish_color_match:\x2d\x2dbackground\x3dbrblue
SET fish_color_normal:normal
SET fish_color_operator:bryellow
SET fish_color_param:cyan
SET fish_color_quote:yellow
SET fish_color_redirection:brblue
SET fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SET fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SET fish_color_user:brgreen
SET fish_color_valid_path:\x2d\x2dunderline
SET fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell
SET fish_key_bindings:fish_default_key_bindings
SET fish_pager_color_completion:\x1d
SET fish_pager_color_description:B3A06D\x1eyellow
SET fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SET fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan

@ -0,0 +1,9 @@
function atril --description "the better atril"
echo -ne "opening "
set_color -i cyan
echo -ne "$argv"
set_color normal
echo " in atril..."
command atril $argv & disown
end

@ -0,0 +1,18 @@
# Defined in /tmp/fish.ZxMSyI/bayern-login.fish @ line 2
function bayern-login
wificonnect @BayernWLAN
set root /home/anton/projects/bavaria-wifi
set_color -o green; echo -e "CONNECTED"; set_color normal
sleep 2
bw-check
#set fname all.min-(date +%Y-%m-%d-%H-%M-%S).js
#set js (curl https://hotspot.vodafone.de/bayern/dist/js/all.min.js)
#set sha (echo -n "$js" | sha1sum | string split " ")[1]
#if ! cat $root/shasums | grep $sha
# echo "$js" > $root/scripts/$fname
# echo "Found new script! sha: $sha. Saved in $root/scripts/$fname"
# echo "$sha" >> $root/shasums
#end
end

@ -0,0 +1,15 @@
# Defined in /tmp/fish.xZCDu4/bw-check.fish @ line 2
function bw-check
set root /home/anton/projects/bavaria-wifi
set fname all.min-(date +%Y-%m-%d-%H-%M-%S).js
set js (curl -s https://hotspot.vodafone.de/bayern/dist/js/all.min.js)
set sha (echo -n "$js" | sha1sum | string split " ")[1]
if ! cat $root/shasums | grep $sha
echo "$js" > $root/scripts/$fname
echo -e "Found new script! sha: $sha.\nSaved in $root/scripts/$fname"
echo "$sha" (date +%Y-%m-%d-%H-%M-%S) >> $root/shasums
else
echo "nothing new"
end
end

@ -0,0 +1,3 @@
function code-py
nix-shell -p python37Packages.pylint --run "code $argv"
end

@ -0,0 +1,4 @@
function dgc-env
set p3p python37Packages
nix-shell -p $p3p.requests $p3p.lxml $p3p.beautifulsoup4 $p3p.clint
end

@ -0,0 +1,19 @@
function fish_greeting
if test "$TERM_PROGRAM" = vscode
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!"
set greet $greetings[(random 1 (count $greetings))]
echo -ne "\n\t"$greet"\n\n"
if test (count (ls -A ~/inbox)) -ne 0;
set_color red
echo -e "\tInbox not empty!"
set_color normal
ls -1 --quoting-style=literal inbox/ | string join ", "
end
end

@ -0,0 +1,37 @@
# Defined in /home/anton/.config/fish/functions/fish_prompt.fish @ line 1
function fish_prompt
set -l git_branch (git branch ^/dev/null | sed -n '/\* /s///p')
if test -n "$git_branch" -a (pwd) != /home/anton
set git_branch " [$git_branch]"
else
set git_branch ""
end
if test -n "$IN_NIX_SHELL"
set_color cyan
echo -n "nix "
set_color normal
end
# set_color cyan
echo -n (whoami)
set_color normal
echo -n '@'
# set_color bryellow
echo -n (hostname)
if status is-interactive-job-control; and test (jobs | wc -l) -gt 0
set_color cyan
echo -n " #"(jobs | wc -l)
end
set_color yellow
echo -n "$git_branch"
set_color green
echo -n ' '(prompt_pwd)
set_color normal
echo ' > '
end

@ -0,0 +1,21 @@
function inbox -d "manipulate your inbox"
if test -z "$argv"
ls -1 --quoting-style=literal ~/inbox/ | string join ", "
return
end
if test "$argv" = "--clear"
rm -r ~/inbox/*
return
end
if echo "$argv" | grep -q " -mv "
set move_flag true
end
if test -f "$argv[1]" -o -d "$argv[1]"
cp -r "$argv[1]" ~/inbox/
else
echo -e (string join "\n" $argv[2..-1])"\n" > ~/inbox/$argv[1]
end
end

@ -0,0 +1,4 @@
# Defined in - @ line 1
function ll --description 'alias ll=ls -AlFh'
ls -AlFh $argv;
end

@ -0,0 +1,4 @@
# Defined in /tmp/fish.dwCY0N/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]"
end

@ -0,0 +1,11 @@
function pythonEnv --description 'start a nix-shell with the given python packages' --argument pythonVersion
if set -q argv[2]
set argv $argv[2..-1]
end
for el in $argv
set ppkgs $ppkgs "python"$pythonVersion"Packages.$el"
end
nix-shell -p $ppkgs
end

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

@ -0,0 +1,4 @@
# Defined in - @ line 1
function vi --description 'alias vi nvim'
nvim $argv;
end

@ -0,0 +1,218 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
# font pango:monospace 8
# remove window bar heading:
for_window [class="^.*"] border pixel 2
smart_borders on
smart_gaps on
gaps inner 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
font pango:DejaVu Sans Mono 8
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.
# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec --no-startup-id nm-applet
# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
# Brightness control
bindsym XF86KbdBrightnessUp exec --no-startup-id /home/anton/.bin/brihgtness +15
bindsym XF86KbdBrightnessDown exec --no-startup-id /home/anton/.bin/brightness -15
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+odiaeresis focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+odiaeresis move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+h split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym odiaeresis resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command i3status | ~/.bin/status-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 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 Shift+s exec --no-startup-id shutdown now, mode "default"
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+End mode "$mode_sys"
# screenshots
bindsym $mod+Print exec flameshot gui

@ -0,0 +1,53 @@
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
output_format = i3bar
colors = true
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"
}
load {
format = "%1min"
}
memory {
format = "%used ~ %available"
threshold_degraded = "1G"
format_degraded = "MEMORY < %available"
}
tztime local {
format = "%Y-%m-%d %H:%M:%S"
}

@ -0,0 +1,189 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./lenovo-configuration.nix
];
# Use the systemd-boot EFI boot loader.
fileSystems.boot.device = "/dev/sda1";
fileSystems.boot.mountPoint = "/boot";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.efi.efiSysMountPoint = "/boot/efi";
boot.loader.grub = {
enable = true;
device = "nodev";
version = 2;
efiSupport = true;
enableCryptodisk = true;
useOSProber = true;
splashImage = "/home/anton/pics/nix-dark-small-red.png";
};
boot.initrd.luks.devices = [
{
name = "root";
device = "/dev/disk/by-uuid/02799bea-98ce-4a38-8772-886303170455";
preLVM = true;
allowDiscards = true;
}
];
boot.kernelParams = [ "noapic" ];
boot.tmpOnTmpfs = true;
networking.hostName = "hostname"; # Define your hostname.
networking.networkmanager = {
wifi.macAddress = "random";
wifi.scanRandMacAddress = true;
# ethernet.macAddress = "random";
enable = true;
};
networking.nameservers = [
"194.150.168.168"
"212.82.226.212"
"1.1.1.1"
];
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour
# networking.useDHCP = false;
networking.interfaces.enp2s0.useDHCP = true;
networking.interfaces.wlp4s0.useDHCP = true;
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "de";
defaultLocale = "en_US.UTF-8";
};
# Set your time zone.
time.timeZone = "Europe/Amsterdam";
# List packages installed in system profile. To search, run:
# $ nix search wget
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
wget vim neovim manpages termite pass coreutils
unzip gzip htop nload firefox ghc vlc gcc python3
fish git file ripgrep os-prober vscode thunderbird
mate.atril xorg.xbacklight gnupg lxqt.pavucontrol-qt
inkscape xorg.xrandr redshift tree
exfat-utils fuse_exfat flameshot ntfs3g
(texlive.combine {
inherit(texlive) scheme-full;
})
];
environment.variables = {
EDITOR = "nvim";
TERMINAL = [ "termite" ];
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
services = {
#redshift = {
# enable = true;
# temperature.night = 2300;
# extraOptions = [ "-l 50.11552:8.68417" ];
#};
xserver = {
enable = true;
layout = "de";
xkbVariant = "nodeadkeys";
windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
};
windowManager.default = "i3";
displayManager.lightdm.enable = true;
libinput.enable = true;
desktopManager.xterm.enable = false;
};
compton.enable = true;
timesyncd.servers = [ "0.nixos.pool.ntp.org" ];
};
programs = {
fish.enable = true;
bash.enableCompletion = true;
};
location = {
latitude = 50.11552;
longitude = 8.68417;
};
# bat state service
# started after xserver is initiated
systemd.user.services.batstate = {
description = "Handles redshift, but flashes the screen red, if the batery level jump below a specific level";
wantedBy = [ "graphical-session.target" ];
enable = true;
environment = { BAT_CRITICAL_LEVEL = "8"; BAT_ALARM_TEMP = "1800"; DISPLAY = ":0"; };
script = "/home/anton/.bin/bat-state";
path = with pkgs; [ fish redshift xorg.xrandr ];
};
systemd.user.services.flameshot = {
description = "Flameshot screenshot service";
wantedBy = [ "graphical-session.target" ];
enable = true;
script = "flameshot";
path = with pkgs; [ flameshot ];
};
# Open ports in the firewall.
networking.firewall.allowedTCPPortRanges = [ {from= 4000; to= 5000;} ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
networking.firewall.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.anton = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "power" "audio" "video" "plugdev" ];
uid = 1000;
createHome = true;
home = "/home/anton";
shell = pkgs.fish;
};
# This value determines the NixOS release with which your system is to be
# compatible, in order to avoid breaking some software such as database
# servers. You should change this only after NixOS release notes say you
# should.
system.stateVersion = "19.09"; # Did you read the comment?
}

@ -0,0 +1,36 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports =
[ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/212b8703-209b-48b5-81d9-928f4cd440a7";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/53ed064a-4da5-477b-84ed-974d9020491d";
fsType = "ext4";
};
fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/6398-D785";
fsType = "vfat";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/a6578ff4-7451-478b-a938-421c69d1ea1e"; }
];
nix.maxJobs = lib.mkDefault 8;
}

@ -0,0 +1,20 @@
{ config, pkgs, ... }:
{
services = {
# power management
#tlp.enable = true;
upower.enable = true;
};
powerManagement.scsiLinkPolicy = "med_power_with_dipm";
# sound
sound.enable = true;
hardware.pulseaudio.enable = true;
# backlight
hardware.acpilight.enable = true;
}

@ -0,0 +1,54 @@
#!/usr/bin/env fish
set DOTFILES_REPO (pwd)
## add thing to dotfiles repository (path or file)
function add_dotfiles
set system "$argv[1]"
set local "$argv[2]"
if grep -q -e "^$local" system_setup
echo "folder $local already in repo!"
return
end
if test -d "$system"
cp -r "$system" "$local"
rm -rf "$system"
else if test -f "$system"
cp "$system" "$local"
rm -f "$system"
else
echo "unknown file type at $argv[1]"
return
end
ln -s "$DOTFILES_REPO"/"$argv[2]" "$argv[1]"
echo "$argv[2] $argv[1]" >> system_setup
end
## link dotfiles everywhere
function restore_system
for line in (cat system_setup)
if test -z $line
continue
end
set line (string split -n " " "$line")
set local "$line[1]"
set system "$line[2]"
echo $local$system
rm -rf "$system"
ln -s "$DOTFILES_REPO"/"$local" "$system"
end
end
if test "$argv[1]" = "add"
add_dotfiles $argv[2..-1]
else if test "$argv[1]" = "build"
restore_system $argv[2..-1]
end

@ -0,0 +1,6 @@
bin /home/anton/.bin
i3 /home/anton/.config/i3
i3status /home/anton/.config/i3status
termite /home/anton/.config/termite
fish /home/anton/.config/fish
nixos /etc/nixos

@ -0,0 +1,10 @@
[options]
audible_bell=1
allow_bold=1
bold_is_bright=1
scrollback_lines=100000
[colors]
#background=#181818
background=rgba(24, 24, 24, 0.8)
Loading…
Cancel
Save