From 331838de061de41f64cd19e9a5eb1e0551b20b24 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 14 Sep 2023 09:57:52 +0200 Subject: [PATCH 1/4] feat(xrandr): Update display organiser script Move to a generic script and load configurations per detected IDs --- .bin/display | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.bin/display b/.bin/display index c7e3a7c..9545c68 100755 --- a/.bin/display +++ b/.bin/display @@ -1,36 +1,22 @@ #!/bin/sh export DISPLAY=:0 -export XAUTHORITY=/home/tanguy/.Xauthority +export XAUTHORITY=~/.Xauthority -/home/tanguy/.screenlayout/base.sh -# TODO : Configure each dock configuration with MAC addresses +DOCK_ID=$(lsusb -d 0x17ef:0x30a9 -v | grep -i iserial | awk '{print $3}') > /dev/null 2>&1 -if [[ "$(ip a | grep 'e0:4f:43:59:98:f4' | wc -l)" == 1 ]]; then - /home/tanguy/.screenlayout/tegl-e0-4f.sh - - i3-msg "workspace 1, move workspace to output DVI-I-1-1"; - i3-msg "workspace 2, move workspace to output DCI-I-2-2"; - i3-msg "workspace 3, move workspace to output eDP-1" - i3-msg "workspace 4, move workspace to output eDP-1" +if [ -z "$DOCK_ID" ]; then + /bin/sh -c ~/.screenlayout/base.sh > /dev/null 2>&1 + /bin/sh -c ~/.bin/workspacelayout/base.sh > /dev/null 2>&1 + exit 0; fi -if [[ "$(ip a | grep 'f4:a8:0d:41:e1:aa' | wc -l)" == 1 ]]; then - /home/tanguy/.screenlayout/tegl-e1-aa.sh +FILE=~/.screenlayout/$DOCK_ID.sh +if test -f $FILE; then + ~/.screenlayout/$DOCK_ID.sh > /dev/null 2>&1 + ~/.bin/workspacelayout/$DOCK_ID.sh > /dev/null 2>&1 - i3-msg "workspace 1, move workspace to output DP-2-2"; - i3-msg "workspace 2, move workspace to output DP-2-3"; - i3-msg "workspace 3, move workspace to output eDP-1" - i3-msg "workspace 4, move workspace to output eDP-1" + echo "Layout applied" fi -if [[ "$(ip a | grep '00:50:b6:f7:e5:d3' | wc -l)" == 1 ]]; then - /home/tanguy/.screenlayout/tegl-e5-d3.sh - - i3-msg "workspace 1, move workspace to output DVI-I-2-2"; - i3-msg "workspace 2, move workspace to output DVI-I-1-1"; - i3-msg "workspace 3, move workspace to output eDP-1" - i3-msg "workspace 4, move workspace to output eDP-1" -fi - -/home/tanguy/.config/polybar/launch.sh > /dev/null 2>&1 +#/home/tanguy/.config/polybar/launch.sh > /dev/null 2>&1 From 5df3a9898cf7fa3c91b6de3dae8b187b38151601 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 14 Sep 2023 09:58:29 +0200 Subject: [PATCH 2/4] feat(cron): Add battery charged indicator --- .config/cron/battery_notifier.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.config/cron/battery_notifier.sh b/.config/cron/battery_notifier.sh index e8b1ff9..f4028cd 100755 --- a/.config/cron/battery_notifier.sh +++ b/.config/cron/battery_notifier.sh @@ -1,14 +1,23 @@ #!/bin/bash +# Crontab entry +# */5 * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) battery_level=$(acpi -b | grep -P -o -m1 "[0-9]+(?=%)") charging_state=$(acpi -b | grep -P -o -m1 "([A-Z])\w+,") # If laptop is charging, do not make further tests -if [ $charging_state = "Charging," ] +if [ $charging_state = "Charging," ] && [ ! -f /tmp/charge_done ] then - exit + if [ $battery_level -ge 100 ] + then + /usr/bin/notify-send "Charge completed" "The battery reached 100% charge." + touch /tmp/charge_done + exit + fi fi +rm -f /tmp/charge_done + if [ $battery_level -le 5 ] then /usr/bin/notify-send "Battery level critical" "Battery level critically low, plug to avoid shutdown" --urgency=critical From 5b8c7040bed79e6dddc17583e0f1754d9cf0d9fb Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 14 Sep 2023 10:00:37 +0200 Subject: [PATCH 3/4] feat(tmux): Add shell environment propagation and refresh function --- .tmux.conf | 2 +- .zshrc | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index 8dd606b..8b91963 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -25,7 +25,7 @@ set-option -g display-panes-colour colour166 #orange set-window-option -g clock-mode-colour green #green # disable DISPLAY requirement when opening pane/window -set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY" +set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY DISPLAY I3SOCK" set -g status-interval 1 set -g status-justify centre # center align window list diff --git a/.zshrc b/.zshrc index 7b5d9ea..f9bb327 100644 --- a/.zshrc +++ b/.zshrc @@ -118,6 +118,29 @@ function wg-reload() { sudo bash -c 'cd /etc/wireguard && wg syncconf $0 <(wg-quick strip $0)' $1 } +if [ -n "$TMUX" ]; then + function refresh { + sshauth=$(tmux show-environment | grep "^SSH_AUTH_SOCK") + if [ $sshauth ]; then + export $sshauth + fi + display=$(tmux show-environment | grep "^DISPLAY") + if [ $display ]; then + export $display + fi + i3sock=$(tmux show-environment | grep "^I3SOCK") + if [ $i3sock ]; then + export $i3sock + fi + } +else + function refresh { } +fi + +function preexec { + refresh +} + # Finally, start a tmux session [ -x "$(command -v tmux)" ] \ && [ -z "${TMUX}" ] \ From bbc565245123b2ae65cbcaae38a9b90d0bbf238f Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 14 Sep 2023 10:10:10 +0200 Subject: [PATCH 4/4] feat(zsh): Reconfigure terraform completion --- .zshrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index f9bb327..421e118 100644 --- a/.zshrc +++ b/.zshrc @@ -6,7 +6,7 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]] fi # Path to your oh-my-zsh installation. -export ZSH="/home/tanguy/.oh-my-zsh" +export ZSH="$HOME/.oh-my-zsh" # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, @@ -28,6 +28,11 @@ then source <(kubectl completion zsh) fi +if [[ $(command -v terraform) ]]; +then + complete -o nospace -C /usr/bin/terraform terraform +fi + # User configuration # You may need to manually set your language environment @@ -151,4 +156,3 @@ function preexec { autoload -U +X bashcompinit && bashcompinit -complete -o nospace -C /usr/bin/terraform terraform