From c5510367db582d1c0683f182dd0e151ea0ab3b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 10 Jun 2022 14:14:22 +0200 Subject: Improvements for NixOS --- config/i3blocks/config | 11 ++--------- config/i3blocks/scripts/allsync | 9 ++++++--- config/i3blocks/scripts/bandwidth | 2 +- config/i3blocks/scripts/email | 2 +- config/i3blocks/scripts/gpu | 4 +--- config/i3blocks/scripts/iface | 2 +- config/i3blocks/scripts/mpd | 2 +- config/sway/bindsym-layout | 4 ++-- config/sway/bindsym-media | 6 +++--- install | 8 ++++++-- local/bin/allsync | 32 ++++++++++++++++++++++++-------- local/bin/sshvnc | 2 +- local/bin/startsway | 9 +++++++-- private | 2 +- vimrc | 3 ++- 15 files changed, 59 insertions(+), 39 deletions(-) diff --git a/config/i3blocks/config b/config/i3blocks/config index 6b8acc8..d60834a 100644 --- a/config/i3blocks/config +++ b/config/i3blocks/config @@ -1,16 +1,14 @@ # i3blocks config file -command=/usr/libexec/i3blocks/$BLOCK_NAME +command=~/.config/i3blocks/scripts/$BLOCK_NAME separator_block_width=10 markup=none [mpd] -command=~/.config/i3blocks/scripts/mpd interval=5 signal=12 -[volume] +[volume-pipewire] label=♪ -instance=Master interval=once signal=10 @@ -23,7 +21,6 @@ interval=10 [gpu] label=gpu: -command=~/.config/i3blocks/scripts/gpu interval=1 [disk] @@ -37,12 +34,10 @@ instance=/home2 interval=30 [iface] -command=~/.config/i3blocks/scripts/iface interval=2 separator=false [bandwidth] -command=~/.config/i3blocks/scripts/bandwidth interval=2 [ssid] @@ -62,12 +57,10 @@ markup=pango interval=30 [allsync] -command=~/.config/i3blocks/scripts/allsync interval=120 signal=13 [email] -command=~/.config/i3blocks/scripts/email interval=30 signal=13 diff --git a/config/i3blocks/scripts/allsync b/config/i3blocks/scripts/allsync index 211799d..472954f 100755 --- a/config/i3blocks/scripts/allsync +++ b/config/i3blocks/scripts/allsync @@ -1,6 +1,9 @@ -#!/bin/bash -if allsync enabled; then +#!/usr/bin/env bash +if allsync enabled 2>/dev/null; then echo "sync" +else echo - echo "#ffff00" fi + +echo +echo "#ffff00" diff --git a/config/i3blocks/scripts/bandwidth b/config/i3blocks/scripts/bandwidth index 9b92274..d45f127 100755 --- a/config/i3blocks/scripts/bandwidth +++ b/config/i3blocks/scripts/bandwidth @@ -38,7 +38,7 @@ if [[ -z $INTERFACE ]] && [[ -n $BLOCK_INSTANCE ]]; then INTERFACE=$BLOCK_INSTANCE elif [[ -z $INTERFACE ]]; then for version in 4 6; do - INTERFACE=$(ip -$version r | sed -n 's/^default.*dev \([^ ]*\).*/\1/p') + INTERFACE=$(ip -$version r | sed -n 's/^default.*dev \([^ ]*\).*/\1/p' | head -1) [ -z "$INTERFACE" ] || break done fi diff --git a/config/i3blocks/scripts/email b/config/i3blocks/scripts/email index d2213e0..01cb5af 100755 --- a/config/i3blocks/scripts/email +++ b/config/i3blocks/scripts/email @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash filter=("tag:unread" "and" "not" "tag:killed") part=() diff --git a/config/i3blocks/scripts/gpu b/config/i3blocks/scripts/gpu index 5153dba..cc257c1 100755 --- a/config/i3blocks/scripts/gpu +++ b/config/i3blocks/scripts/gpu @@ -1,4 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash echo "$(cat /sys/class/drm/card0/device/gpu_busy_percent)%" -echo -echo diff --git a/config/i3blocks/scripts/iface b/config/i3blocks/scripts/iface index ffa576e..5daffa6 100755 --- a/config/i3blocks/scripts/iface +++ b/config/i3blocks/scripts/iface @@ -20,7 +20,7 @@ # Use the provided interface, otherwise the device used for the default route. IF="${IFACE:-$BLOCK_INSTANCE}" for version in 4 6; do - IF="${IF:-$(ip -$version route | sed -n 's/^default.*dev \([^ ]*\).*/\1/p')}" + IF="${IF:-$(ip -$version route | sed -n 's/^default.*dev \([^ ]*\).*/\1/p' | head -1)}" done # Exit if there is no default route diff --git a/config/i3blocks/scripts/mpd b/config/i3blocks/scripts/mpd index 0f3764d..d179511 100755 --- a/config/i3blocks/scripts/mpd +++ b/config/i3blocks/scripts/mpd @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash status="$(mpc -f "♫ %artist%, %album%, %title%" status)" diff --git a/config/sway/bindsym-layout b/config/sway/bindsym-layout index ef14ead..5b075ac 100644 --- a/config/sway/bindsym-layout +++ b/config/sway/bindsym-layout @@ -9,5 +9,5 @@ mode "$mode_layout" { bindsym --to-code $mod+slash mode "$mode_layout" # Type emoji -bindsym --to-code $mod+period exec rofimoji --skin-tone neutral -bindsym --to-code $mod+Shift+period exec rofimoji --skin-tone neutral --action copy +bindsym --to-code $mod+period exec rofimoji --selector wofi --skin-tone neutral +bindsym --to-code $mod+Shift+period exec rofimoji --selector wofi --skin-tone neutral --action copy diff --git a/config/sway/bindsym-media b/config/sway/bindsym-media index 5b75934..c72491a 100644 --- a/config/sway/bindsym-media +++ b/config/sway/bindsym-media @@ -1,8 +1,8 @@ # vim: ft=swayconfig # Audio control -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && pkill -RTMIN+10 i3blocks -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && pkill -RTMIN+10 i3blocks -bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -RTMIN+10 i3blocks +bindsym XF86AudioRaiseVolume exec --no-startup-id wpctl set-volume @DEFAULT_SINK@ 0.05+ && pkill -RTMIN+10 i3blocks +bindsym XF86AudioLowerVolume exec --no-startup-id wpctl set-volume @DEFAULT_SINK@ 0.05- && pkill -RTMIN+10 i3blocks +bindsym XF86AudioMute exec --no-startup-id wpctl set-volume @DEFAULT_AUDIO_SINK@ toggle && pkill -RTMIN+10 i3blocks # Run and configure pulsemixer bindsym $mod+p exec alacritty -t "Pulsemixer" -e pulsemixer diff --git a/install b/install index 86fe425..6c5edbb 100755 --- a/install +++ b/install @@ -1,6 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash -cd `dirname $0` +cd "$(dirname "$0")" || exit 1 git submodule update --init --recursive || (echo "Submodule update failed!"; exit 5) @@ -34,6 +34,7 @@ if ask "gnuscreen" "Install configurations for various utility tools"; then fi if ask "ssh" "Install SSH config"; then + mkdir -p ~/.cache/ssh # directory for sockets inst private/ssh_config ~/.ssh/config inst local/bin/sshvnc ~/.local/bin/sshvnc fi @@ -60,6 +61,9 @@ fi if ask "sync" "Install synchronization"; then inst local/bin/allsync ~/.local/bin/allsync + if [ "$(ps -o comm= 1)" = "systemd" ]; then + inst config/systemd/user/allsync.{service,timer} ~/.config/systemd/user/ + fi inst private/mbsyncrc ~/.mbsyncrc inst private/notmuch-config ~/.notmuch-config diff --git a/local/bin/allsync b/local/bin/allsync index c268b97..e5bb633 100755 --- a/local/bin/allsync +++ b/local/bin/allsync @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu cronline="* * * * * /bin/sh -c 'AUTORUN=y /home/cynerd/.local/bin/allsync'" @@ -16,20 +16,32 @@ i3_astroid() { cron_enable() { pass mail/cynerd@email.cz >/dev/null # Cache keys - { - crontab -l - echo "$cronline" - } | crontab - + if command -v crontab >/dev/null; then + { + crontab -l + echo "$cronline" + } | crontab - + else + systemctl --user start allsync.timer + fi notify_i3block } cron_disable() { - crontab -l | grep -Fv "$cronline" | crontab - + if command -v crontab >/dev/null; then + crontab -l | grep -Fv "$cronline" | crontab - + else + systemctl --user stop allsync.timer + fi notify_i3block } cron_enabled() { - crontab -l | grep -Fq "$cronline" + if command -v crontab >/dev/null; then + crontab -l | grep -Fq "$cronline" + else + systemctl --user is-active allsync.timer >/dev/null + fi } if [ "$#" -gt 0 ]; then @@ -67,6 +79,7 @@ fi ################################################################################## +flock_nonblock="" if [ "${AUTORUN:-n}" = "y" ]; then exec &> >(logger -t "${0##*/}") @@ -75,10 +88,13 @@ if [ "${AUTORUN:-n}" = "y" ]; then cron_disable exit 1 fi + flock_nonblock="--nonblock" fi if [ "${ALLSYNC_FLOCK:-n}" != "y" ]; then - ALLSYNC_FLOCK=y exec flock --exclusive "$HOME/.mail" "$0" "$@" + ALLSYNC_FLOCK=y exec flock $flock_nonblock --exclusive "$HOME/.mail" "$0" "$@" + echo "Another instance is alredy running" >&2 + exit 1 fi diff --git a/local/bin/sshvnc b/local/bin/sshvnc index af133b4..fcee459 100755 --- a/local/bin/sshvnc +++ b/local/bin/sshvnc @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu target="$1" diff --git a/local/bin/startsway b/local/bin/startsway index 63163ee..1639277 100755 --- a/local/bin/startsway +++ b/local/bin/startsway @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu exec 1> >(logger -s -t "${0##*/}") 2>&1 @@ -17,4 +17,9 @@ export MOZ_ENABLE_WAYLAND=1 # Java application do not display properly export _JAVA_AWT_WM_NONREPARENTING=1 -exec dbus-run-session sway +dbus="dbus-run-session" +if command -v systemctl >/dev/null; then + dbus="" +fi + +exec $dbus sway diff --git a/private b/private index c5c5030..9e3fb5c 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit c5c5030068d0f290fd729aedb6c78bc855b5c8c5 +Subproject commit 9e3fb5c8a8c48bc1a26a68bc1c072d70447ced88 diff --git a/vimrc b/vimrc index c1d1247..defcef1 100644 --- a/vimrc +++ b/vimrc @@ -53,7 +53,6 @@ Plugin 'rhysd/vim-grammarous' call vundle#end() filetype plugin indent on -colorscheme elflord syntax on set exrc @@ -77,6 +76,8 @@ function FoldText() endfunction +set backspace=indent,eol,start + set number set colorcolumn=80 set textwidth=80 -- cgit v1.2.3