diff options
Diffstat (limited to '')
-rw-r--r-- | home/nipsy/arrakis/mutt/muttrc | 2 | ||||
-rw-r--r-- | home/nipsy/common/core/vim/vimrc | 4 | ||||
-rw-r--r-- | home/nipsy/common/optional/desktops/i3/default.nix | 7 | ||||
-rwxr-xr-x | home/nipsy/common/optional/desktops/i3/xscreensaver-activate | 100 | ||||
-rw-r--r-- | home/root/arrakis.nix | 54 | ||||
-rw-r--r-- | home/root/common/core/vim/vimrc | 4 |
6 files changed, 143 insertions, 28 deletions
diff --git a/home/nipsy/arrakis/mutt/muttrc b/home/nipsy/arrakis/mutt/muttrc index f77c5bf..1293092 100644 --- a/home/nipsy/arrakis/mutt/muttrc +++ b/home/nipsy/arrakis/mutt/muttrc @@ -53,7 +53,7 @@ set confirmcreate=no # prompt when creating new files set copy=yes # always save a copy of outgoing messages set delete=yes # purge deleted messages without asking set edit_headers # let me edit the message header when composing -set editor="vim -c 'set textwidth=65'" # editor to use when composing messages +set editor="vim -c 'set textwidth=65' -c 'set noautoindent' -c 'set formatoptions+=a'" # editor to use when composing messages #set editor="/usr/bin/nvi" # editor to use when composing messages #set editor="/usr/bin/vi" # editor to use when composing messages set fast_reply # skip initial prompts when replying diff --git a/home/nipsy/common/core/vim/vimrc b/home/nipsy/common/core/vim/vimrc index 9f652cd..87de2a0 100644 --- a/home/nipsy/common/core/vim/vimrc +++ b/home/nipsy/common/core/vim/vimrc @@ -43,5 +43,5 @@ set hlsearch " highlight all search matches set laststatus=2 set statusline=%<%f%h%m%r%=%{&ff}\ %Y\ %b\ 0x%B\ \ %l,%c%V\ %P -map <F5> :w<CR><bar>:!clear;go run %<CR> -map <F6> :w<CR><bar>:%! gofmt<CR> +"map <F5> :w<CR><bar>:!clear;go run %<CR> +"map <F6> :w<CR><bar>:%! gofmt<CR> diff --git a/home/nipsy/common/optional/desktops/i3/default.nix b/home/nipsy/common/optional/desktops/i3/default.nix index c7a521d..bbfc50c 100644 --- a/home/nipsy/common/optional/desktops/i3/default.nix +++ b/home/nipsy/common/optional/desktops/i3/default.nix @@ -36,6 +36,8 @@ foreground = #e5e5e5 cursor-color = #ffffff ''; + + "bin/xscreensaver-activate".source = ./xscreensaver-activate; }; packages = [ @@ -79,6 +81,11 @@ always = true; notification = false; } + { + command = "~/bin/xscreensaver-activate"; + always = true; + notification = false; + } ]; window.border = 0; window.commands = [ diff --git a/home/nipsy/common/optional/desktops/i3/xscreensaver-activate b/home/nipsy/common/optional/desktops/i3/xscreensaver-activate new file mode 100755 index 0000000..edcfa62 --- /dev/null +++ b/home/nipsy/common/optional/desktops/i3/xscreensaver-activate @@ -0,0 +1,100 @@ +#!/usr/bin/env zsh + +# bail out if xscreensaver isn't installed +if [[ ! -x =xscreensaver ]]; then + echo "no xscreensaver command found, ${0:t} bailing out" >&2 + exit 0 +fi + +# record our own PID to avoid duplicate invocations +PIDFILE="/dev/shm/${0:t}.pid" + +# check for already running script +if [[ -f ${PIDFILE} ]]; then + for i in $(pidof -x ${0:t}); do + if [[ ${i} -eq $(cat ${PIDFILE}) ]]; then + echo "${0:t} already running!" >&2 + exit 1 + fi + done +fi + +# record current PID +echo ${$} > ${PIDFILE} + +# wait a bit for everything to start +sleep 30 + +# check whether xscreensaver itself is running and start it if not +if ! systemctl --user --quiet is-active xscreensaver.service; then + systemctl --user start xscreensaver.service +fi + +# retrieve current Xorg screen size so we know where the corners are +xrandr | grep ^Screen | grep -Eo 'current [[:digit:]]+ x [[:digit:]]+' | cut -d' ' -f2,4 | read max_x max_y +echo "read screen size as ${max_x} x ${max_y}" + +# main loop +while true; do + + # retrieve current mouse position and set environment variables + eval $(xdotool getmouselocation --shell) + + # keep xscreensaver deactivated if we're in the top right corner of the screen + if [[ ${X} -eq $((max_x - 1)) && ${Y} -eq $((max_y - max_y)) ]]; then + + # make sure xscreensaver is even running before telling it to stay idle + if pidof xscreensaver &>/dev/null; then + sleep 5 + xscreensaver-command -deactivate &>/dev/null + fi + + # mouse is in the top left corner -- potentially activate xscreensaver right now + elif [[ ${X} -eq $((max_x - max_x)) && ${Y} -eq $((max_y - max_y)) ]]; then + + # sleep a bit and then check mouse coordinates again + sleep 5 + eval $(xdotool getmouselocation --shell) + + # mouse is still in the top left corner -- we must really want to activate xscreensaver + if [[ ${X} -eq $((max_x - max_x)) && ${Y} -eq $((max_y - max_y)) ]]; then + + # make sure xscreensaver is actually running + if pidof xscreensaver &>/dev/null; then + + # make sure it hasn't already activated + if ! xscreensaver-command -time | grep -q 'screen blanked since'; then + + # activate it! + xscreensaver-command -activate &>/dev/null + + fi + + fi + + fi + + # a Steam game is running + elif ps axfu | grep '/home/nipsy/.steam/debian-installation/steamapps/common' | grep -qv grep; then + + # make sure xscreensaver is even running before telling it to stay idle + if pidof xscreensaver &>/dev/null; then + sleep 5 + xscreensaver-command -deactivate &>/dev/null + fi + + fi + + # die off if we're no longer running on a connected Xorg screen any longer -- this should be the normal termination path for this script + if ! xdpyinfo &>/dev/null; then + rm ${PIDFILE} + exit 0 + fi + + # arbitrary sleep for script to avoid CPU sucking infinite loop + sleep 5 + +done + +# exit with error since we should never get here +exit 1 diff --git a/home/root/arrakis.nix b/home/root/arrakis.nix index b852ce5..ac7a30a 100644 --- a/home/root/arrakis.nix +++ b/home/root/arrakis.nix @@ -9,16 +9,16 @@ executable = true; text = '' #!${pkgs.zsh}/bin/zsh - + function status_vpn { - + ip netns exec vpn su -c 'curl -m 10 -s https://bitgnome.net/ip/ | grep REMOTE_ADDR' nipsy ip netns exec vpn su -c 'curl -m 10 -s https://www.cloudflarestatus.com | grep "Cloudflare Status"' nipsy - + } - + function start_vpn { - + ip netns add vpn ip link add veth.host type veth peer veth.vpn ip link set dev veth.host up @@ -32,44 +32,52 @@ ip -n vpn link set wg1 up ip -n vpn route add default dev wg1 ip netns exec vpn nft -f /etc/nftables-vpn.conf - + } - + function stop_vpn { - - ip netns del vpn - ip link del veth.host - + + systemctl stop prowlarr.service qbittorrent.service + + if ip netns | grep -q '^vpn '; then + ip netns del vpn + fi + + if ip link show veth.host > /dev/null; then + ip link del veth.host + fi + } - + if [[ -z "''${1}" || "''${1}" == "status" ]]; then - + status_vpn - + elif [[ "''${1}" == "restart" ]]; then - + stop_vpn sleep 2 start_vpn - + systemctl restart prowlarr.service qbittorrent.service + elif [[ "''${1}" == "restart_firewall" ]]; then - + ip netns exec vpn nft -f /etc/nftables-vpn.conf - + elif [[ "''${1}" == "start" ]]; then - + if [[ ! -f /run/netns/vpn ]]; then start_vpn else echo 'VPN service already appears to be running' >&2 fi - + elif [[ "''${1}" == "stop" ]]; then - + stop_vpn - + fi - + exit 0 ''; }; diff --git a/home/root/common/core/vim/vimrc b/home/root/common/core/vim/vimrc index 9f652cd..87de2a0 100644 --- a/home/root/common/core/vim/vimrc +++ b/home/root/common/core/vim/vimrc @@ -43,5 +43,5 @@ set hlsearch " highlight all search matches set laststatus=2 set statusline=%<%f%h%m%r%=%{&ff}\ %Y\ %b\ 0x%B\ \ %l,%c%V\ %P -map <F5> :w<CR><bar>:!clear;go run %<CR> -map <F6> :w<CR><bar>:%! gofmt<CR> +"map <F5> :w<CR><bar>:!clear;go run %<CR> +"map <F6> :w<CR><bar>:%! gofmt<CR> |