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 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 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..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 @@ -118,6 +123,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}" ] \ @@ -128,4 +156,3 @@ function wg-reload() { autoload -U +X bashcompinit && bashcompinit -complete -o nospace -C /usr/bin/terraform terraform