few fixes, mostly x related improvements
[distro-setup] / .bashrc
diff --git a/.bashrc b/.bashrc
index 0376fd6796dc15e51b99e49d3360c43761e473c8..814c9af63136b822811da9ba20c1af02beaa1ff4 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -55,6 +55,11 @@ HISTIGNORE='pass *:otp *:oathtool *:histrm *'
 umask 022
 
 
+if [[ $EUID == 1000 && $TERM == linux && ! $DISPLAY && $(tty) = /dev/tty1 && -x /usr/bin/startx ]] && \
+     tmp=$(systemctl status |& head) && \
+     grep -qi '^ *state: running' <<<"$tmp"  && grep -qi '^ *failed: 0' <<<"$tmp" && grep -qi '^ *jobs: 0' <<<"$tmp"; then
+  startx
+fi
 
 #### if (in
 # noninteractive ssh shells or tty). tty because often i use it when
@@ -129,7 +134,7 @@ return 0
 
 # Automatically added by the Guix install script.
 if [ -n "$GUIX_ENVIRONMENT" ]; then
-    if [[ $PS1 =~ (.*)"\\$" ]]; then
-        PS1="${BASH_REMATCH[1]} [env]\\\$ "
-    fi
+  if [[ $PS1 =~ (.*)"\\$" ]]; then
+    PS1="${BASH_REMATCH[1]} [env]\\\$ "
+  fi
 fi