mirror of
https://github.com/kmein/niveum
synced 2026-03-16 18:21:07 +01:00
35c3
+ scripts as derivations ~ move home-mananger stuff to the right modules / dot + home-manager ssh config - vim: powerline symbols ~ toggle keyboard with alt+shift + ssh agent at startup ~ retiolum ipv6 ~ texlive packages ~ shell: vim mode + THEMING ~ i3 minimaler + q ~ terminal: use urxvt
This commit is contained in:
45
dot/dunst.nix
Normal file
45
dot/dunst.nix
Normal file
@@ -0,0 +1,45 @@
|
||||
{ config, pkgs }:
|
||||
with import ../theme.nix;
|
||||
{
|
||||
enable = true;
|
||||
iconTheme = config.constants.theme.icon;
|
||||
settings = {
|
||||
global = {
|
||||
transparency = 10;
|
||||
font = "${uiFont.name} ${toString uiFont.size}";
|
||||
geometry = "200x5-30+20";
|
||||
frame_color = invertedColorScheme.background;
|
||||
follow = "mouse";
|
||||
indicate_hidden = true;
|
||||
notification_height = 0;
|
||||
separator_height = 2;
|
||||
padding = 8;
|
||||
horizontal_padding = 8;
|
||||
separator_color = "auto";
|
||||
sort = true;
|
||||
markup = "full";
|
||||
format = ''%a\n<b>%s</b>\n%b'';
|
||||
alignment = "left";
|
||||
show_age_threshold = 60;
|
||||
bounce_freq = 0;
|
||||
word_wrap = true;
|
||||
ellipsize = "middle";
|
||||
ignore_newline = false;
|
||||
stack_duplicates = true;
|
||||
hide_duplicate_count = false;
|
||||
max_icon_size = 32;
|
||||
sticky_history = true;
|
||||
history_length = 20;
|
||||
dmenu = "${pkgs.rofi}/bin/rofi -display-run dunst -show run";
|
||||
browser = "${pkgs.xdg_utils}/bin/xdg-open";
|
||||
verbosity = "mesg";
|
||||
corner_radius = 0;
|
||||
mouse_left_click = "do_action";
|
||||
mouse_right_click = "close_current";
|
||||
mouse_middle_click = "close_all";
|
||||
};
|
||||
urgency_low = { frame_color = invertedColorScheme.background; background = invertedColorScheme.background; foreground = invertedColorScheme.foreground; timeout = 5; };
|
||||
urgency_normal = { frame_color = invertedColorScheme.background; background = invertedColorScheme.background; foreground = invertedColorScheme.foreground; timeout = 10; };
|
||||
urgency_critical = { frame_color = invertedColorScheme.red.dark; background = invertedColorScheme.red.dark; foreground = invertedColorScheme.foreground; timeout = 0; };
|
||||
};
|
||||
}
|
||||
90
dot/i3.nix
Normal file
90
dot/i3.nix
Normal file
@@ -0,0 +1,90 @@
|
||||
{ pkgs, config, lib }:
|
||||
let
|
||||
unstable = import <nixos-unstable> {};
|
||||
i3blocks_conf = import ./i3blocks.nix { inherit pkgs; };
|
||||
new-workspace = unstable.writers.writeDash "new-workspace" ''
|
||||
i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
|
||||
'';
|
||||
move-to-new-workspace = unstable.writers.writeDash "new-workspace" ''
|
||||
i3-msg move container to workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
|
||||
'';
|
||||
in with import ../theme.nix;
|
||||
rec {
|
||||
fonts = [ "${uiFont.name} ${toString uiFont.size}" ];
|
||||
modifier = "Mod4";
|
||||
window = {
|
||||
titlebar = false;
|
||||
border = 1;
|
||||
hideEdgeBorders = "smart";
|
||||
};
|
||||
floating = {
|
||||
titlebar = false;
|
||||
border = 1;
|
||||
};
|
||||
colors =
|
||||
let scheme = { background = colorScheme.background; text = colorScheme.foreground; };
|
||||
in {
|
||||
focused = scheme // {
|
||||
border = colorScheme.background;
|
||||
indicator = colorScheme.background;
|
||||
childBorder = colorScheme.background;
|
||||
};
|
||||
focusedInactive = scheme // {
|
||||
border = colorScheme.background;
|
||||
indicator = colorScheme.background;
|
||||
childBorder = colorScheme.background;
|
||||
};
|
||||
unfocused = scheme // {
|
||||
border = colorScheme.background;
|
||||
indicator = colorScheme.background;
|
||||
childBorder = colorScheme.background;
|
||||
};
|
||||
urgent = scheme // {
|
||||
border = colorScheme.red.light;
|
||||
indicator = colorScheme.red.light;
|
||||
childBorder = colorScheme.red.light;
|
||||
};
|
||||
placeholder = scheme // {
|
||||
border = colorScheme.green.light;
|
||||
indicator = colorScheme.green.light;
|
||||
childBorder = colorScheme.green.light;
|
||||
};
|
||||
};
|
||||
bars = [];
|
||||
keybindings = {
|
||||
"${modifier}+Down" = "focus down";
|
||||
"${modifier}+Left" = "focus left";
|
||||
"${modifier}+Return" = "exec ${config.defaultApplications.terminal}";
|
||||
"${modifier}+Right" = "focus right";
|
||||
"${modifier}+Shift+Down" = "move down";
|
||||
"${modifier}+Shift+Left" = "move left";
|
||||
"${modifier}+Shift+Right" = "move right";
|
||||
"${modifier}+Shift+Up" = "move up";
|
||||
"${modifier}+Shift+c" = "reload";
|
||||
"${modifier}+Shift+n" = "rove window to workspace next";
|
||||
"${modifier}+Shift+b" = "move window to workspace prev";
|
||||
"${modifier}+Shift+q" = "kill";
|
||||
"${modifier}+Shift+r" = "restart";
|
||||
"${modifier}+Shift+w" = "exec ${pkgs.xautolock}/bin/xautolock -locknow";
|
||||
"${modifier}+Shift+x" = "exec --no-startup-id ${move-to-new-workspace}";
|
||||
"${modifier}+Shift+z" = "floating toggle";
|
||||
"${modifier}+Up" = "focus up";
|
||||
"${modifier}+a" = "exec ${pkgs.rofi}/bin/rofi -display-window — -show window";
|
||||
"${modifier}+d" = "exec ${pkgs.rofi}/bin/rofi -display-run — -show run";
|
||||
"${modifier}+e" = "layout toggle split";
|
||||
"${modifier}+f" = "fullscreen toggle";
|
||||
"${modifier}+h" = "split h";
|
||||
"${modifier}+n" = "workspace next";
|
||||
"${modifier}+b" = "workspace prev";
|
||||
"${modifier}+r" = "mode resize";
|
||||
"${modifier}+s" = "layout stacking";
|
||||
"${modifier}+t" = "exec ${config.defaultApplications.fileManager}";
|
||||
"${modifier}+v" = "split v";
|
||||
"${modifier}+w" = "layout tabbed";
|
||||
"${modifier}+x" = "exec --no-startup-id ${new-workspace}";
|
||||
"${modifier}+y" = "exec ${config.defaultApplications.browser}";
|
||||
"XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -d 5 && pkill -RTMIN+3 i3blocks";
|
||||
"XF86AudioMute" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -t && pkill -RTMIN+3 i3blocks";
|
||||
"XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -i 5 && pkill -RTMIN+3 i3blocks";
|
||||
};
|
||||
}
|
||||
183
dot/i3blocks.nix
Normal file
183
dot/i3blocks.nix
Normal file
@@ -0,0 +1,183 @@
|
||||
{ pkgs }:
|
||||
let
|
||||
unstable = import <nixos-unstable> {};
|
||||
spotify_info = unstable.writers.writeBash "spotify.info" ''
|
||||
if $(pgrep spotify); then
|
||||
STATUS=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$)
|
||||
|
||||
if [[ "$STATUS" == 'Playing' ]]; then
|
||||
printf '\uf1bc '
|
||||
printf '\uf04b'
|
||||
elif [[ "$STATUS" == 'Paused' ]]; then
|
||||
printf '\uf1bc '
|
||||
printf '\uf04c'
|
||||
elif [[ "$STATUS" == 'Stopped' ]]; then
|
||||
printf '\uf1bc '
|
||||
printf '\uf04d'
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf ' '
|
||||
|
||||
METADATA=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata')
|
||||
ARTIST=$(echo "$METADATA" | egrep -A 2 "artist" | egrep -v "artist" | egrep -v "array" | cut -b 27- | cut -d '"' -f 1 | egrep -v ^$)
|
||||
TITLE=$(echo "$METADATA" | egrep -A 1 "title" | egrep -v "title" | cut -b 44- | cut -d '"' -f 1 | egrep -v ^$)
|
||||
|
||||
printf "%s \u2237 %s" "$ARTIST" "$TITLE"
|
||||
fi
|
||||
'';
|
||||
battery_info = unstable.writers.writeBash "battery.info" ''
|
||||
BAT_DIR="/sys/class/power_supply/$BLOCK_INSTANCE/"
|
||||
if [ -d "$BAT_DIR" ]; then
|
||||
cd "$BAT_DIR"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e charge_now ] && [ -e charge_full ]; then
|
||||
FULL_CHARGE=charge_full
|
||||
CURR_CHARGE=charge_now
|
||||
elif [ -e energy_now ] && [ -e energy_full ]; then
|
||||
FULL_CHARGE=energy_full
|
||||
CURR_CHARGE=energy_now
|
||||
else
|
||||
ls >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
status=$(cat status)
|
||||
charge_f=$((100 * $(cat $CURR_CHARGE) / $(cat $FULL_CHARGE)))
|
||||
|
||||
if [[ "$charge_f" -lt 20 ]]; then
|
||||
printf '\uf244'
|
||||
elif [[ "$charge_f" -lt 40 ]]; then
|
||||
printf '\uf243'
|
||||
elif [[ "$charge_f" -lt 60 ]]; then
|
||||
printf '\uf242'
|
||||
elif [[ "$charge_f" -lt 80 ]]; then
|
||||
printf '\uf241'
|
||||
else
|
||||
printf '\uf240'
|
||||
fi
|
||||
|
||||
printf ' '
|
||||
|
||||
if [[ "$status" == 'Charging' ]]; then
|
||||
printf '\uf106'
|
||||
elif [[ "$status" == 'Discharging' ]]; then
|
||||
printf '\uf107'
|
||||
elif [[ "$status" == 'Full' ]]; then
|
||||
printf '\uf0e7'
|
||||
else
|
||||
printf '[%s]' "$status"
|
||||
fi
|
||||
|
||||
printf ' '
|
||||
|
||||
if [[ "$status" != 'Full' ]]; then
|
||||
rate_raw=$(($(cat voltage_now) * $(cat power_now)))
|
||||
rate=$(bc <<< "scale=1; $rate_raw / 10^12")
|
||||
printf '%s\u2009W, ' "$rate"
|
||||
fi
|
||||
|
||||
charge_d=$((100 * $(cat $CURR_CHARGE) / $(cat $FULL_CHARGE)))
|
||||
printf '%s%%\n' "$charge_d"
|
||||
|
||||
if [[ "$status" == 'Discharging' ]]; then
|
||||
if [[ "$charge_d" -lt 10 ]]; then
|
||||
printf '\n#E41C28'
|
||||
elif [[ "$charge_d" -lt 20 ]]; then
|
||||
printf '\n#EEBF13'
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
volume_info = unstable.writers.writeBash "volume.info" ''
|
||||
if [[ "$BLOCK_BUTTON" == 1 ]]; then
|
||||
${pkgs.pamixer}/bin/pamixer -i 5
|
||||
elif [[ "$BLOCK_BUTTON" == 3 ]]; then
|
||||
${pkgs.pamixer}/bin/pamixer -d 5
|
||||
elif [[ "$BLOCK_BUTTON" == 2 ]]; then
|
||||
${pkgs.pamixer}/bin/pamixer -t
|
||||
fi
|
||||
|
||||
if $(${pkgs.pamixer}/bin/pamixer --get-mute); then
|
||||
printf '\uf026 0%%\n\n#EEBF13'
|
||||
else
|
||||
volume=$(${pkgs.pamixer}/bin/pamixer --get-volume)
|
||||
printf '\uf028 %s%%' "$volume"
|
||||
fi
|
||||
'';
|
||||
fancyDate = unstable.writers.writeC "fancy_date.c" {} ''
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int main(void) {
|
||||
time_t now = time(NULL);
|
||||
struct tm *today = localtime(&now);
|
||||
wchar_t roman_month = 0x2160 + today->tm_mon;
|
||||
wprintf(L"%d\u2009%lc\u2009%d [%d|%d]\n", today->tm_mday, roman_month, 1900 + today->tm_year, today->tm_wday == 0 ? 7 : today->tm_wday, today->tm_yday/7 + 1);
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in with import ../theme.nix; ''
|
||||
markup=pango
|
||||
align=center
|
||||
color=${white}
|
||||
|
||||
[spotify]
|
||||
command=${spotify_info}
|
||||
interval=2
|
||||
|
||||
[separator]
|
||||
|
||||
[volume]
|
||||
command=${volume_info}
|
||||
min_width= 100%
|
||||
interval=once
|
||||
signal=3
|
||||
|
||||
[separator]
|
||||
|
||||
[cpu_usage]
|
||||
command=cut -d' ' -f 1-3 < /proc/loadavg
|
||||
label=
|
||||
interval=2
|
||||
|
||||
[separator]
|
||||
|
||||
[ram_usage]
|
||||
command=free -h | grep "Mem" | awk '{print $3}'
|
||||
label=
|
||||
interval=2
|
||||
align=center
|
||||
|
||||
[separator]
|
||||
|
||||
[battery]
|
||||
command=${battery_info}
|
||||
interval=10
|
||||
instance=BAT1
|
||||
|
||||
[separator]
|
||||
|
||||
[date]
|
||||
command=${fancyDate}
|
||||
interval=1
|
||||
label=
|
||||
|
||||
[separator]
|
||||
|
||||
[time]
|
||||
command=date +'%H:%M'
|
||||
interval=1
|
||||
label=
|
||||
|
||||
[separator]
|
||||
command=${pkgs.xkblayout-state}/bin/xkblayout-state print %s
|
||||
label=
|
||||
interval=2
|
||||
|
||||
[separator]
|
||||
''
|
||||
34
dot/rofi.nix
Normal file
34
dot/rofi.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{ config }:
|
||||
with import ../theme.nix;
|
||||
{
|
||||
enable = true;
|
||||
separator = "solid";
|
||||
scrollbar = false;
|
||||
terminal = config.defaultApplications.terminal;
|
||||
borderWidth = 0;
|
||||
lines = 5;
|
||||
font = "${uiFont.name} ${toString (uiFont.size + 1)}";
|
||||
colors = rec {
|
||||
window = { background = invertedColorScheme.background; border = invertedColorScheme.background; separator = invertedColorScheme.black.light; };
|
||||
rows = {
|
||||
normal = {
|
||||
background = window.background;
|
||||
backgroundAlt = window.background;
|
||||
foreground = invertedColorScheme.foreground;
|
||||
highlight = { foreground = invertedColorScheme.cyan.dark; inherit (window) background; };
|
||||
};
|
||||
active = {
|
||||
background = window.background;
|
||||
backgroundAlt = window.background;
|
||||
foreground = invertedColorScheme.yellow.dark;
|
||||
highlight = { foreground = invertedColorScheme.green.dark; inherit (window) background; };
|
||||
};
|
||||
urgent = {
|
||||
background = window.background;
|
||||
backgroundAlt = window.background;
|
||||
foreground = invertedColorScheme.red.dark;
|
||||
highlight = { foreground = invertedColorScheme.magenta.dark; inherit (window) background; };
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
481
dot/scripts.nix
481
dot/scripts.nix
@@ -1,6 +1,8 @@
|
||||
{ pkgs }:
|
||||
let
|
||||
bingWallpaper = pkgs.writers.writeBash "bing-wallpaper.sh" ''
|
||||
theme = import ../theme.nix;
|
||||
unstable = import <nixos-unstable> {};
|
||||
bingWallpaper = unstable.writers.writeBash "bing-wallpaper.sh" ''
|
||||
PICTURE_DIR="$HOME/pictures/external/bing/"
|
||||
|
||||
mkdir -p $PICTURE_DIR
|
||||
@@ -17,18 +19,7 @@ let
|
||||
fi
|
||||
done
|
||||
'';
|
||||
colorize = pkgs.writers.writeDash "colorize.sh" ''
|
||||
colorize() {
|
||||
${pkgs.python36Packages.pygments}/bin/pygmentize -l $1 -O bg=dark
|
||||
}
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
colorize "$1"
|
||||
else
|
||||
cat "$2" | colorize "$1"
|
||||
fi
|
||||
'';
|
||||
easyBackup = pkgs.writers.writeDash "easy-backup.sh" ''
|
||||
easyBackup = unstable.writers.writeDash "easy-backup" ''
|
||||
if [ -d "$1" ]; then
|
||||
OUTPUT_ROOT=''${1}/backup/current
|
||||
rsync -hav --delete --stats --progress --exclude-from=$HOME/bin/backup.exclude $HOME/* $OUTPUT_ROOT/
|
||||
@@ -37,107 +28,7 @@ let
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
compile = pkgs.writers.writeBash "compile.sh" ''
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: compile <source file>"
|
||||
fi
|
||||
|
||||
file="$1"
|
||||
ext="''${file##*.}"
|
||||
name="''${file%.*}"
|
||||
|
||||
case "$ext" in
|
||||
asm)
|
||||
echo Compiling "$name" with the Netwide Assembler...
|
||||
nasm -felf64 -o "$name".o "$file"
|
||||
gcc -o "$name" "$name".o;;
|
||||
c)
|
||||
echo Compiling "$name" with the GNU C Compiler...
|
||||
gcc -std=c11 -Wall -Wpedantic -Ofast -o "$name" "$file";;
|
||||
cpp|cxx|cc)
|
||||
echo Compiling "$name" with the GNU C++ Compiler...
|
||||
g++ -std=c++11 -Wall -O3 -o "$name" "$file";;
|
||||
bf)
|
||||
echo Compiling "$name" with the BrainFuck Compiler...
|
||||
bf2c "$file" "$name".c && compile "$name".c && rm "$name".c;;
|
||||
s)
|
||||
echo Assembling "$name" with the GNU Assembler...
|
||||
gcc -o "$name" "$file";;
|
||||
hs)
|
||||
echo Compiling "$name" with the Glasgow Haskell Compiler...
|
||||
stack ghc -- -Wall -O3 --make "$file" && rm "$name".hi "$name".o;;
|
||||
java)
|
||||
echo Compiling "$name" with the Oracle Java Compiler...
|
||||
javac "$file";;
|
||||
rb)
|
||||
echo Compiling "$name" with Ruby...
|
||||
ruby -c "$file";;
|
||||
lua)
|
||||
echo Compiling "$name" with the Lua Compiler...
|
||||
luac -o "$name".luac "$file";;
|
||||
py)
|
||||
if [ ""$2"" = "--optimize" ]; then
|
||||
echo Compiling "$name" with the optimizing Python Compiler...
|
||||
if [ -e "$name".pyo ]; then
|
||||
rm "$name".pyo
|
||||
fi
|
||||
python3 -O -mpy_compile "$file"
|
||||
mv __pycache__/"$name".cpython-33.pyo ./"$name".pyo
|
||||
rmdir __pycache__
|
||||
else
|
||||
echo Compiling "$name" with the Python Compiler...
|
||||
if [ -e "$name".pyc ]; then
|
||||
rm "$name".pyc
|
||||
fi
|
||||
python3 -mpy_compile "$file"
|
||||
mv __pycache__/"$name".cpython-33.pyc ./"$name".pyc
|
||||
rmdir __pycache__
|
||||
fi;;
|
||||
ml)
|
||||
echo Compiling "$name" with the OCaml Compiler...
|
||||
ocamlc -o "$name" "$file" && rm "$name".cmo "$name".cmi;;
|
||||
cs)
|
||||
echo Compiling "$name" with the Mono C£ Compiler...
|
||||
mono-csc -out:"$name" "$file";;
|
||||
fs)
|
||||
echo Compiling "$name" with the F£ Compiler...
|
||||
fsharpc -out:"$name" "$file";;
|
||||
vala)
|
||||
echo Compiling "$name" with the Vala Compiler...
|
||||
valac --pkg=gtk+-3.0 "$file";;
|
||||
md)
|
||||
echo Converting "$name" to PDF with Pandoc...
|
||||
pandoc --latex-engine=xelatex -V documentclass=scrartcl -o "$name".pdf "$file";;
|
||||
tex)
|
||||
echo Compiling "$name" to PDF with LaTeX...
|
||||
latexmk -pdf "$file";;
|
||||
lhs)
|
||||
echo Compiling "$name" with the Glasgow Haskell Compiler...
|
||||
ghc -Wall -O3 --make "$file"
|
||||
echo Converting "$name" to PDF Markup with Pandoc...
|
||||
pandoc "$file" -f markdown+lhs --latex-engine=xelatex -V documentclass=scrartcl -o "$name".pdf;;
|
||||
d)
|
||||
echo Compiling "$name" with the GNU D Compiler...
|
||||
gdc -Wall -O3 -o "$name" "$file";;
|
||||
m)
|
||||
echo Compiling "$name" with the GNU/GNUstep Objective C Compiler...
|
||||
£ gcc -Wall -o "$name" -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -fPIC -DGSWARN -Wno-import -g -O2 -fgnu-runtime -fconstant-string-class=NSConstantString -fexec-charset=UTF-8 -I. -I/usr/local/include/GNUstep -I/usr/include/GNUstep -lobjc -lgnustep-base "$file"
|
||||
gcc `gnustep-config --objc-flags` "$file" -o "$name" -lgnustep-base -lobjc
|
||||
;;
|
||||
pas)
|
||||
echo Compiling "$name" with the FreePascal Compiler...
|
||||
fpc "$file";;
|
||||
rs)
|
||||
echo Compiling "$name" with the Rust Compiler...
|
||||
rustc "$file";;
|
||||
ts)
|
||||
echo Compiling "$name" with the TypeScript Compiler...
|
||||
tsc "$file";;
|
||||
*)
|
||||
echo Compiler for "$ext" not found!;;
|
||||
esac
|
||||
'';
|
||||
gitPullAll = pkgs.writers.writeDash "git-pull-all.sh" ''
|
||||
gitPullAll = unstable.writers.writeDashBin "pull-all" ''
|
||||
# store the current dir
|
||||
CUR_DIR=$(pwd)
|
||||
# Let the person running the script know what's going on.
|
||||
@@ -156,196 +47,7 @@ let
|
||||
done
|
||||
echo -e "\n\033[32mComplete!\033[0m\n"
|
||||
'';
|
||||
gripe = pkgs.writers.writeBash "gripe.sh" ''${sidepipe} '(:\d+:|-\d+-|--)(\x1b[[]K)?' "$@"'';
|
||||
haskellDefinition = pkgs.writers.writeBash "hdef.sh" ''
|
||||
paths=""
|
||||
while true; do
|
||||
if [ -d "$1" ]; then
|
||||
paths="$paths $1"
|
||||
else
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
str="$1"
|
||||
shift
|
||||
|
||||
lower=$(echo "$str" | tr A-Z a-z)
|
||||
if [ "''${lower:0:1}" == "''${str:0:1}" ]; then
|
||||
expr="($str( |$)|[[:space:]]+$str[[:space:]]*::)"
|
||||
else
|
||||
kws="(class|data|type|newtype)"
|
||||
eow="([ \n\t]|$)"
|
||||
expr="$kws[[:space:]]+($str$eow|[^=]+=>[[:space:]]+$str$eow)"
|
||||
fi
|
||||
|
||||
${haskellFind} $paths -print0 | xargs -0 grep -En --colour=never -A10 "$@" "^$expr" | ${gripe} hcol | ${highlight} $str
|
||||
'';
|
||||
haskellFind = pkgs.writers.writeDash "hfind.sh" ''
|
||||
paths=""
|
||||
while true; do
|
||||
if [ -d "$1" ]; then
|
||||
paths="$paths $1"
|
||||
else
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
find $paths \( -name "*.hs" -or -name "*.hsi" -or -name "*.lhs" -or -name "*.hs-boot" \) -a -not \( -name ".*" -or -path "*/_darcs/*" -o -name '.£*' \) "$@"
|
||||
'';
|
||||
haskellGrep = pkgs.writers.writeDash "hgrep.sh" ''
|
||||
if [ -z "$1" -o "$1" == "--help" -o "$1" == "-h" ]; then
|
||||
echo "Usage: hg [PATH] IDENTIFIER [GREP OPTIONS...]"
|
||||
echo "Seaches for uses of the given Haskell identifier."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
paths=""
|
||||
while true; do
|
||||
if [ -d "$1" ]; then
|
||||
paths="$paths $1"
|
||||
else
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
colour=always
|
||||
if [ "$TERM" == "dumb" -o "$NO_COLORS" == "1" ]; then
|
||||
colour=never
|
||||
fi
|
||||
${haskellFind} $paths -print0 | xargs -0 grep -nw --colour=$colour "$@"
|
||||
'';
|
||||
highlight = pkgs.writers.writePython3 "hl.py" {
|
||||
libraries = [ pkgs.python36Packages.ansicolors ];
|
||||
flakeIgnore = [ "E302" "E999" "E231" "E701" "W605" "E231" "E305" ];
|
||||
} ''
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
from ansicolors import *
|
||||
|
||||
def replfun((re,colfun)):
|
||||
def onmatch(m):
|
||||
if m.groups() != ():
|
||||
buf = []
|
||||
p = m.start(0)
|
||||
mstr = m.string
|
||||
try:
|
||||
i = 1
|
||||
while True:
|
||||
(s,e) = m.span(i)
|
||||
if s == -1: continue
|
||||
buf.append(mstr[p:s])
|
||||
buf.append(colfun(mstr[s:e]))
|
||||
p = e
|
||||
i += 1
|
||||
except IndexError:
|
||||
buf.append(mstr[p:m.end(0)])
|
||||
return '\'.join(buf)
|
||||
else:
|
||||
return colfun(m.expand("\g<0>"))
|
||||
return lambda s: re.subn(onmatch,s)[0]
|
||||
|
||||
colfuns = [green, red, magenta, cyan, blue]
|
||||
flags = re.L
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '-i':
|
||||
flags = flags | re.I
|
||||
exps = sys.argv[2:]
|
||||
else:
|
||||
exps = sys.argv[1:]
|
||||
regexps = map(lambda e: re.compile(e, flags), exps)
|
||||
hlfuns = map(replfun, zip(regexps, colfuns))
|
||||
|
||||
term = os.getenv("TERM")
|
||||
no_colors = os.getenv("NO_COLORS")
|
||||
if term == "dumb" or no_colors == "1":
|
||||
for line in sys.stdin:
|
||||
sys.stdout.write(line)
|
||||
else:
|
||||
for line in sys.stdin:
|
||||
sys.stdout.write(reduce(lambda s, f: f(s), hlfuns, line))
|
||||
'';
|
||||
haskellTags = pkgs.writers.writeDash "htags.sh" ''
|
||||
id="[a-z_][a-zA-Z0-9_\']*"
|
||||
ws="[ \\t]"
|
||||
ID="[A-Z][a-zA-Z0-9_\']*"
|
||||
|
||||
${pkgs.ctags}/bin/ctags --tag-relative=no \
|
||||
'--langdef=haskell' \
|
||||
'--langmap=haskell:.hs.lhs' \
|
||||
'--regex-haskell=/^(type|data|newtype)[ \t]+([^ \t=]+)/\2/' \
|
||||
'--regex-haskell=/^class[^=]+=>[ \t]*([^ \t]+)/\1/' \
|
||||
'--regex-haskell=/^class[ \t]+([^ \t]+)[^=]*$/\1/' \
|
||||
"--regex-haskell=/^$ws*($id)$ws*::/\1/" \
|
||||
"--regex-haskell=/^($id)/\1/" \
|
||||
"$@"
|
||||
'';
|
||||
sidepipe = pkgs.writers.writePython3 "sidepipe.py" { flakeIgnore = [ "E302" "E231" "E999" "E265" "E305" ]; } ''
|
||||
import sys
|
||||
import re
|
||||
import os.path
|
||||
from Queue import Queue
|
||||
from subprocess import Popen, PIPE
|
||||
from threading import Thread
|
||||
|
||||
pipeIsLeft = os.path.basename(sys.argv[0]) == "leftpipe"
|
||||
regex = sys.argv[1]
|
||||
cmd = sys.argv[2:]
|
||||
|
||||
class WorkerThread(Thread):
|
||||
def __init__(self, queue, instream, outstream, pipeIsLeft):
|
||||
Thread.__init__(self)
|
||||
self.queue = queue
|
||||
self.instream = instream
|
||||
self.outstream = outstream
|
||||
self.pipeIsLeft = pipeIsLeft
|
||||
|
||||
class SplitThread(WorkerThread):
|
||||
def run(self):
|
||||
try:
|
||||
for line in self.instream:
|
||||
match = re.search(regex,line)
|
||||
if not match:
|
||||
print >> sys.stderr, "No match: %r in %r" % (regex,line)
|
||||
continue
|
||||
index = match.end()
|
||||
left, right = line[:index], line[index:]
|
||||
if pipeIsLeft:
|
||||
self.outstream.write(left)
|
||||
self.queue.put(right)
|
||||
else:
|
||||
self.outstream.write(right)
|
||||
self.queue.put(left)
|
||||
self.outstream.close()
|
||||
except IOError, e:
|
||||
print >> sys.stderr, e[1]
|
||||
self.outstream.close()
|
||||
while not queue.full():
|
||||
queue.put("")
|
||||
|
||||
class JoinThread(WorkerThread):
|
||||
def run(self):
|
||||
for pipeline in self.instream:
|
||||
#print >> sys.stderr, "wait"
|
||||
passline = self.queue.get()
|
||||
#print >> sys.stderr, "ok"
|
||||
if pipeIsLeft:
|
||||
self.outstream.write(pipeline)
|
||||
self.outstream.write(passline)
|
||||
else:
|
||||
self.outstream.write(passline)
|
||||
self.outstream.write(pipeline)
|
||||
|
||||
pipe = Popen(cmd, shell=False,stdin=PIPE,stdout=PIPE)
|
||||
queue = Queue(250)
|
||||
t1 = SplitThread(queue, sys.stdin, pipe.stdin, pipeIsLeft)
|
||||
t2 = JoinThread(queue, pipe.stdout, sys.stdout, pipeIsLeft)
|
||||
t1.start()
|
||||
t2.start()
|
||||
t2.join()
|
||||
'';
|
||||
spotifyCli = pkgs.writers.writeBash "sp.sh" ''
|
||||
spotifyCli = unstable.writers.writeBashBin "sp" ''
|
||||
# This is sp, the command-line Spotify controller. It talks to a running
|
||||
# instance of the Spotify Linux client over dbus, providing an interface not
|
||||
# unlike mpc.
|
||||
@@ -616,29 +318,158 @@ let
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
spotifyGenius = pkgs.writers.writeBash "spgenius.sh" ''
|
||||
spotifyGenius = unstable.writers.writeDashBin "spgenius.sh" ''
|
||||
function normalise {
|
||||
echo ''${1// /-}
|
||||
echo "$1" | tr ' ' -
|
||||
}
|
||||
eval $(${spotifyCli} eval)
|
||||
${pkgs.xdg_utils}/bin/xdg-open "http://genius.com/$(normalise "$SPOTIFY_ARTIST")-$(normalise "$SPOTIFY_TITLE")-lyrics"
|
||||
'';
|
||||
generateShellNix = pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/kmein/generate-shell-nix/81f77661705ee628d1566f2dea01f2d731fda79d/generate-shell-nix";
|
||||
sha256 = "0r661z9s5zw0gas2f73aakplfblj1jjlbijmm7gf513xkq61jxm8";
|
||||
executable = true;
|
||||
};
|
||||
in {
|
||||
compile = compile;
|
||||
easy-backup = easyBackup;
|
||||
colorize = colorize;
|
||||
bing-wallpaper = bingWallpaper;
|
||||
git-pull-all = gitPullAll;
|
||||
hdef = haskellDefinition;
|
||||
hfind = haskellFind;
|
||||
hgrep = haskellGrep;
|
||||
htags = haskellTags;
|
||||
sp = spotifyCli;
|
||||
spgenius = spotifyGenius;
|
||||
generate-shell-nix = generateShellNix;
|
||||
}
|
||||
generateShellNix =
|
||||
let generateShellNixPath = pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/kmein/generate-shell-nix/81f77661705ee628d1566f2dea01f2d731fda79d/generate-shell-nix";
|
||||
sha256 = "0r661z9s5zw0gas2f73aakplfblj1jjlbijmm7gf513xkq61jxm8";
|
||||
executable = true;
|
||||
};
|
||||
in unstable.writers.writeDashBin "generate-shell-nix" ''${generateShellNixPath} $*'';
|
||||
dic =
|
||||
let dicPath = pkgs.fetchurl {
|
||||
url = "https://cgit.krebsco.de/dic/plain/dic?id=beeca40313f68874e05568f4041423c16202e9da";
|
||||
sha256 = "1d25pm420fnbrr273i96syrcd8jkh8qnflpfgxlsbzmbmfizfzld";
|
||||
executable = true;
|
||||
};
|
||||
in unstable.writers.writeDashBin "dic" ''${dicPath} $*'';
|
||||
font-size = unstable.writers.writeDashBin "font-size" ''
|
||||
set -efu
|
||||
|
||||
# set_font NORMAL_FONT BOLD_FONT
|
||||
set_font() {
|
||||
printf '\033]710;%s\007' "$1"
|
||||
printf '\033]711;%s\007' "$2"
|
||||
}
|
||||
|
||||
case ''${1-} in
|
||||
'''|0|--reset)
|
||||
set_font \
|
||||
"xft:${theme.terminalFont.name}:size=${toString theme.terminalFont.size}" \
|
||||
"xft:${theme.terminalFont.name}:size=${toString theme.terminalFont.size}:bold" \
|
||||
;;
|
||||
[2-9]|[1-9][0-9]|[1-9][0-9][0-9])
|
||||
set_font \
|
||||
"xft:${theme.terminalFont.name}:size=$1" \
|
||||
"xft:${theme.terminalFont.name}:size=$1:bold" \
|
||||
;;
|
||||
*)
|
||||
echo "$0: bad argument: $1" >&2
|
||||
exit 1
|
||||
esac
|
||||
'';
|
||||
wttr = unstable.writers.writeDashBin "wttr" ''
|
||||
${pkgs.curl}/bin/curl -s -H "Accept-Language: ''${LANG%_*}" --compressed "wttr.in/''${1-$(${pkgs.curl}/bin/curl -s ipinfo.io | ${pkgs.jq}/bin/jq .loc)}?0"
|
||||
'';
|
||||
q =
|
||||
let
|
||||
q-performance = ''
|
||||
show_load() {
|
||||
${pkgs.coreutils}/bin/cat /proc/loadavg | ${pkgs.gawk}/bin/gawk '{ print $1, $2, $3}'
|
||||
}
|
||||
|
||||
show_memory() {
|
||||
${pkgs.procps}/bin/free -h | ${pkgs.gnugrep}/bin/grep "Mem" | ${pkgs.gawk}/bin/gawk '{print $3}'
|
||||
}
|
||||
|
||||
printf "\x1b[33m%s \x1b[1m%s\x1b[0m\n" "$(show_load)" "$(show_memory)"
|
||||
'';
|
||||
q-isodate = ''
|
||||
${pkgs.coreutils}/bin/date '+[1m%Y-%m-%d[0m [35m%H:%M[0m:%S%:z'
|
||||
'';
|
||||
q-volume = ''
|
||||
is_mute() {
|
||||
if $(${pkgs.pamixer}/bin/pamixer --get-mute); then
|
||||
echo "(Mute)"
|
||||
else
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
current_volume() {
|
||||
${pkgs.pamixer}/bin/pamixer --get-volume
|
||||
}
|
||||
|
||||
printf "\x1b[36m%d%%\x1b[0m %s\n" "$(current_volume)" "$(is_mute)"
|
||||
'';
|
||||
q-online = ''
|
||||
if ${pkgs.curl}/bin/curl -s google.com >/dev/null; then
|
||||
echo '[32;1monline[0m'
|
||||
else
|
||||
echo '[31;1moffline[0m'
|
||||
fi
|
||||
'';
|
||||
q-battery = ''
|
||||
BAT_DIR="/sys/class/power_supply/BAT1/"
|
||||
if test ! -d "$BAT_DIR"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -e "$BAT_DIR/charge_now" -a -e "$BAT_DIR/charge_full"; then
|
||||
FULL_CHARGE="$BAT_DIR/charge_full"
|
||||
CURR_CHARGE="$BAT_DIR/charge_now"
|
||||
elif test -e "$BAT_DIR/energy_now" -a -e "$BAT_DIR/energy_full"; then
|
||||
FULL_CHARGE="$BAT_DIR/energy_full"
|
||||
CURR_CHARGE="$BAT_DIR/energy_now"
|
||||
else
|
||||
ls >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
STATUS="$BAT_DIR/status"
|
||||
|
||||
charge_d=$((100 * $(${pkgs.coreutils}/bin/cat $CURR_CHARGE) / $(${pkgs.coreutils}/bin/cat $FULL_CHARGE)))
|
||||
if [[ "$charge_d" -lt 10 ]]; then
|
||||
printf "\x1b[31m"
|
||||
elif [[ "$charge_d" -lt 20 ]]; then
|
||||
printf "\x1b[33m"
|
||||
else
|
||||
printf "\x1b[32m"
|
||||
fi
|
||||
|
||||
printf '%s%%\x1b[0m (%s)\n' "$charge_d" $(${pkgs.coreutils}/bin/cat "$STATUS")
|
||||
'';
|
||||
q-todo = ''
|
||||
TODO_file=$PWD/.todo
|
||||
if test -e "$TODO_file"; then
|
||||
printf "\n\x1b[1mTodo\x1b[0m\n"
|
||||
${pkgs.coreutils}/bin/cat "$TODO_file" \
|
||||
| ${pkgs.gawk}/bin/gawk -v now=$(${pkgs.coreutils}/bin/date +%s) '
|
||||
BEGIN { print "remind=0" }
|
||||
/^[0-9]/{
|
||||
x = $1
|
||||
gsub(".", "\\\\&", x)
|
||||
rest = substr($0, index($0, " "))
|
||||
rest = $0
|
||||
sub(" *", "", rest)
|
||||
gsub(".", "\\\\&", rest)
|
||||
print "test $(${pkgs.coreutils}/bin/date +%s -d"x") -lt "now" && \
|
||||
echo \"\x1b[93m\""rest esc "\"\x1b[m\" && \
|
||||
(( remind++ ))"
|
||||
}
|
||||
END { print "test $remind = 0 && echo \"nothing to remind\"" }
|
||||
' \
|
||||
| {
|
||||
# bash needed for (( ... ))
|
||||
${pkgs.bash}/bin/bash
|
||||
}
|
||||
fi
|
||||
'';
|
||||
in unstable.writers.writeBashBin "q" ''
|
||||
set -eu
|
||||
export PATH=/var/empty
|
||||
${q-isodate}
|
||||
${q-performance}
|
||||
(${q-volume}) &
|
||||
(${q-battery}) &
|
||||
(${q-online}) &
|
||||
wait
|
||||
(${q-todo}) || :
|
||||
'';
|
||||
in [ spotifyCli dic easyBackup gitPullAll font-size generateShellNix q wttr ]
|
||||
|
||||
28
dot/ssh.nix
28
dot/ssh.nix
@@ -1,22 +1,10 @@
|
||||
{ lib }:
|
||||
with lib;
|
||||
let huServer = name: ''
|
||||
Host ${name}
|
||||
User ${(import ../secrets.nix).eduroam.identity}
|
||||
HostName ${name}.informatik.hu-berlin.de
|
||||
IdentityFile ~/.ssh/hu
|
||||
'';
|
||||
in ''
|
||||
Host github
|
||||
User git
|
||||
HostName github.com
|
||||
|
||||
Host gitlab
|
||||
User git
|
||||
HostName gitlab.informatik.hu-berlin.de
|
||||
|
||||
Host happysrv
|
||||
User meinhark
|
||||
HostName v22017123717458308.happysrv.de
|
||||
Port 49000
|
||||
'' + strings.concatMapStringsSep "\n\n" huServer [ "rabe" "star" "gruenau" "gruenau1" "gruenau2" "gruenau3" "gruenau4" "gruenau5" "gruenau6" "gruenau7" "gruenau8" ]
|
||||
let huServer = name: {
|
||||
"${name}" = {
|
||||
hostname = "${name}.informatik.hu-berlin.de";
|
||||
user = (import ../secrets.nix).eduroam.identity;
|
||||
identityFile = "~/.ssh/hu";
|
||||
};
|
||||
};
|
||||
in lists.foldr (x: xs: huServer x // xs) {} [ "rabe" "star" "gruenau" "gruenau1" "gruenau2" "gruenau3" "gruenau4" "gruenau5" "gruenau6" "gruenau7" "gruenau8" ]
|
||||
|
||||
15
dot/urxvt.nix
Normal file
15
dot/urxvt.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{ pkgs }:
|
||||
with import ../theme.nix;
|
||||
{
|
||||
enable = true;
|
||||
package = pkgs.rxvt_unicode-with-plugins;
|
||||
keybindings = {
|
||||
"Shift-Control-C" = "eval:selection_to_clipboard";
|
||||
"Shift-Control-V" = "eval:paste_clipboard";
|
||||
};
|
||||
scroll.bar.enable = false;
|
||||
extraConfig = {
|
||||
perl-ext-common = "default,clipboard,url-select,keyboard-select";
|
||||
fading = 50;
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
''
|
||||
XTerm*termName: xterm-256color
|
||||
XTerm*locale: true
|
||||
XTerm*saveLines: 4096
|
||||
XTerm*geometry: 80x32
|
||||
XTerm*reverseVideo: true
|
||||
XTerm*faceName: Source Code Pro for Powerline:size=10:antialias=true
|
||||
XTerm*font: 7x13
|
||||
Xterm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48
|
||||
XTerm*translations: #override \n\
|
||||
Ctrl Shift <Key>C: copy-selection(CLIPBOARD) \n\
|
||||
Ctrl Shift <Key>V: insert-selection(CLIPBOARD)
|
||||
''
|
||||
{ lib }:
|
||||
let theme = import ../theme.nix;
|
||||
in with lib; lists.foldr
|
||||
(i: cs: cs // { "*color${toString i}" = builtins.elemAt theme.colorPalette i; })
|
||||
{
|
||||
"*background" = theme.colorScheme.background;
|
||||
"*foreground" = theme.colorScheme.foreground;
|
||||
"*fadeColor" = theme.colorScheme.fadeColor;
|
||||
"*cursorColor" = theme.colorScheme.cursorColor;
|
||||
"*pointerColorForeground" = theme.colorScheme.pointerColorForeground;
|
||||
"*pointerColorBackground" = theme.colorScheme.pointerColorBackground;
|
||||
"*.font" = "xft:${theme.terminalFont.name}:size=${toString theme.terminalFont.size}";
|
||||
"*.boldFont" = "xft:${theme.terminalFont.name}:style=Bold:size=${toString theme.terminalFont.size}";
|
||||
"*.italicFont" = "xft:${theme.terminalFont.name}:style=Italic:size=${toString theme.terminalFont.size}";
|
||||
}
|
||||
(lists.range 0 15)
|
||||
|
||||
5
dot/zathura.nix
Normal file
5
dot/zathura.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
options = {
|
||||
selection-clipboard = "clipboard";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user