From 6299a5256659120e832b365e9cec9e38f0d2dddd Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Sun, 23 May 2021 17:33:00 +0200 Subject: [PATCH] more stuff --- bin/backup_frumar.sh | 5 ++ bin/undock.sh | 13 ++++ color-scheme | 1 + nix/.config/nixpkgs/waybar/config | 86 ++++++++++++++++++++++ nix/.config/nixpkgs/waybar/style.css | 102 +++++++++++++++++++++++++++ nr.fish | 59 ++++++++++++++++ 6 files changed, 266 insertions(+) create mode 100755 bin/backup_frumar.sh create mode 100755 bin/undock.sh create mode 100644 color-scheme create mode 100644 nix/.config/nixpkgs/waybar/config create mode 100644 nix/.config/nixpkgs/waybar/style.css create mode 100644 nr.fish diff --git a/bin/backup_frumar.sh b/bin/backup_frumar.sh new file mode 100755 index 0000000..f72d717 --- /dev/null +++ b/bin/backup_frumar.sh @@ -0,0 +1,5 @@ +#!/bin/sh +export BORG_REPO="frumar.local:/data/yorick/backup" +export BORG_PASSCOMMAND="pass sysadmin/jarvis-borg" +borg create "::home-{hostname}-{user}-{now}" $HOME --exclude-from ~/dotfiles/misc/.borgignore -x --compression=zstd -v +~/dotfiles/bin/borgbackup.sh prune --prefix "home-{hostname}-{user}" --keep-daily=4 --keep-weekly=4 --keep-monthly=6 --keep-yearly=2 --list --stats diff --git a/bin/undock.sh b/bin/undock.sh new file mode 100755 index 0000000..f8f2c38 --- /dev/null +++ b/bin/undock.sh @@ -0,0 +1,13 @@ +#!/bin/sh +echo "undocking..." | systemd-cat -t dotfiles -p info +# if [ -e /sys/bus/pci/devices/0000\:04\:00.0/remove ]; then +# echo 1 | sudo tee /sys/bus/pci/devices/0000\:04\:00.0/remove +# echo "removed pci bridge" +# sleep 2s +# else +# echo "No pci device found, ignoring" +# fi +systemd-inhibit --what=handle-lid-switch sleep 45s & disown +swaymsg output '*' disable +swaymsg output eDP-1 enable +exit 0 diff --git a/color-scheme b/color-scheme new file mode 100644 index 0000000..162faa6 --- /dev/null +++ b/color-scheme @@ -0,0 +1 @@ +light diff --git a/nix/.config/nixpkgs/waybar/config b/nix/.config/nixpkgs/waybar/config new file mode 100644 index 0000000..7107991 --- /dev/null +++ b/nix/.config/nixpkgs/waybar/config @@ -0,0 +1,86 @@ +{ + "layer": "top", // Waybar at top layer + // "position": "bottom", // Waybar at the bottom of your screen + "height": 26, // Waybar height + // "width": 1280, // Waybar width + // Choose the order of the modules + "modules-left": ["sway/workspaces", "sway/mode", "custom/spotify"], + "modules-center": ["sway/window"], + "modules-right": ["pulseaudio", "network", "disk", "battery", "clock", "tray"], + // Modules configuration + "sway/workspaces": { + "all-outputs": false, + "format": "{icon} {name}", + "format-icons": { + "1": "", + "2": "#", + "3": "", + "4": "", + "5": "", + "6": "", + "7": "", + "urgent": "", + "focused": "", + "default": "" + } + }, + "sway/mode": { + "format": "{}" + }, + "tray": { + // "icon-size": 21, + "spacing": 10 + }, + "clock": { + "format-alt": "{:%Y-%m-%d}" + }, + "cpu": { + "format": "{load}% " + }, + "memory": { + "format": "{}% " + }, + "disk": { + "format": "{free} " + }, + "battery": { + "states": { + // "good": 95, + "warning": 30, + "critical": 15 + }, + "format": "{capacity}% {icon}", + // "format-good": "", // An empty format will hide the module + // "format-full": "", + "format-icons": ["", "", "", "", ""] + }, + "network": { + //"interface": "wlp58s0", // (Optional) To force the use of this interface + "format-wifi": "{essid} ", + "format-ethernet": "{ifname} ", + "format-disconnected": "Disconnected ⚠" + }, + "pulseaudio": { + "scroll-step": 5, + "format": "{volume}% {icon}", + "format-bluetooth": "{volume}% {icon}", + "format-muted": "", + "format-icons": { + "headphones": "", + "handsfree": "", + "headset": "", + "phone": "", + "portable": "", + "car": "", + "default": ["", ""] + }, + "on-click": "pavucontrol" + }, + "custom/spotify": { + "format": " {}", + "escape": true, + "max-length": 40, + "on-click": "playerctl play-pause", + "exec": "$HOME/dotfiles/bin/spotify_meta.sh 2> /dev/null" // Script in resources folder + } +} diff --git a/nix/.config/nixpkgs/waybar/style.css b/nix/.config/nixpkgs/waybar/style.css new file mode 100644 index 0000000..ce96472 --- /dev/null +++ b/nix/.config/nixpkgs/waybar/style.css @@ -0,0 +1,102 @@ +* { + border: none; + border-radius: 0; + font-family: Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; + min-height: 0; +} + +window#waybar { + background: rgba(43, 48, 59, 0.5); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: white; +} + +#workspaces button { + padding: 0 5px; + background: transparent; + color: white; + border-bottom: 3px solid transparent; +} + +#workspaces button.focused { + background: #64727D; + border-bottom: 3px solid white; +} + +#mode { + background: #64727D; + border-bottom: 3px solid white; +} + +#clock, #battery, #cpu, #memory, #network, #disk, #pulseaudio, #custom-spotify, #tray, #mode { + padding: 0 10px; + margin: 0 5px; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: black; +} + +#battery.charging { + color: white; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: black; + } +} + +#battery.warning:not(.charging) { + background: #f53c3c; + color: white; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +#cpu, #disk { + background: #2ecc71; + color: #000000; +} + +#memory { + background: #9b59b6; +} + +#network { + background: #2980b9; +} + +#network.disconnected { + background: #f53c3c; +} + +#pulseaudio { + background: #f1c40f; + color: black; +} + +#pulseaudio.muted { + background: #90b1b1; + color: #2a5c45; +} + +#custom-spotify { + background: #66cc99; + color: #2a5c45; +} + +#tray { + background-color: #2980b9; +} diff --git a/nr.fish b/nr.fish new file mode 100644 index 0000000..d6f016a --- /dev/null +++ b/nr.fish @@ -0,0 +1,59 @@ +function __nr_apply + set -l out $argv[1] + set -l man (nix-store -q -b man $out 2>&1) + echo "Adding $out ..." + + if [ -d "$man/share/man" ] + set -a MANPATH "$man/share/man" + end + + if [ -d "$out/share/man" ] + set -a MANPATH "$out/share/man" + end + + set -a PATH "$out/bin" + + if [ -f "$out/nix-support/propagated-user-env-packages" ] + for f in (cat "$out/nix-support/propagated-user-env-packages") + __nr_apply $f + end + end +end +# Defined in /tmp/fish.OJ1yiT/nr.fish @ line 2 +function :u + if ! set -q __NR_OLD_PATH + set -g __NR_OLD_PATH $PATH + set -g __NR_OLD_MANPATH $MANPATH + end + + if [ (count $argv) -eq 0 ] + set -xg PATH $__NR_OLD_PATH + set -xg MANPATH $__NR_OLD_MANPATH + end + + for arg in $argv + set -l out (nix-instantiate --eval --json --expr ' +let + tryImport = f: with builtins; let v = import f; in if isFunction v && (any (a: a) (attrValues (functionArgs v))) then v {} else v; + isImportable = path: with builtins; if pathExists "${path}/" then pathExists "${path}/default.nix" else pathExists "${path}"; + + pathBits = with builtins; map ({ prefix, path }: + if prefix == "" then + let + contents = readDir path; + names = builtins.filter (a: contents.${a} == "directory" && isImportable "${path}/${a}") (attrNames contents); + in + foldl\' (prev: val: prev // { ${val} = tryImport "${path}/${val}"; }) {} names + else + if isImportable path then + { ${prefix} = tryImport path; } + else + { } + ) nixPath; + + out = builtins.foldl\' (old: new: old // new) {} pathBits; +in with out; builtins.toPath ('"$arg"').outPath' | jq -r .) + [ -e $out ] || nix-store -r $out > /dev/null + __nr_apply $out + end +end