Skip to content

Instantly share code, notes, and snippets.

@theit8514
Created June 3, 2015 16:03
Show Gist options
  • Select an option

  • Save theit8514/c495fedaf4b039fa73ab to your computer and use it in GitHub Desktop.

Select an option

Save theit8514/c495fedaf4b039fa73ab to your computer and use it in GitHub Desktop.
Same as auto-start-for-i3-simple, except includes ability to search for a specific window name (eg: feh creates a window, but it doesn't attach it to a pid) and to be able to search child pids for windows (eg: running a batch script which runs a lxterm/xterm/uxterm)
#! /bin/sh
# Simple autostart file for i3-wm, you can execute it from i3 config with
# exec $HOME/bin/auto-start-for-i3-simple
#
# xdotool and xmessage must be installed. On BSD use jot instead of
# seq or install seq from ports.
# Max seconds to wait until the process is up
MAXWAIT=30
# Start the given command and wait until it's visible
StartProg()
{
window=
case $1 in
-w | --window )
shift
window=$1
shift
;;
esac
"$@" & # Handle arguments with whitspaces
mypid=$! # Pid of last background process
for i in `seq $MAXWAIT`; do # count from 1 to MAXWAIT
if [ -z "$window" ]; then
children=$(pstree -pn $mypid | grep -o "([[:digit:]]*)" | grep -o "[[:digit:]]*")
for cpid in $children; do
if xdotool search --onlyvisible --pid $cpid; then
return 0
fi
done
else
if xdotool search --onlyvisible --name $window; then
return 0
fi
fi
sleep 1
done
xmessage "Error on executing: $@" &
}
# Start some programs
#
# ______________________
# | | |
# | lxterm | firefox |
# | | |
# | | |
# |----------|----------|
# | feh | lxterm |
# |__________|__________|
i3-msg workspace 1
StartProg lxterm
i3-msg split h
sleep 2
StartProg firefox
i3-msg split v
sleep 5
StartProg $HOME/bin/lxhtop
sleep 1
i3-msg focus left
sleep 1
i3-msg split v
sleep 1
StartProg -w feh $HOME/bin/FGfeh
sleep 5
i3-msg workspace 2
StartProg $HOME/bin/lxtorguard
exit 0
#!/bin/sh
feh -xrz.Z --image-bg black --slideshow-delay 30 --no-fehbg /path/to/Backgrounds
#!/bin/sh
lxterm -e bash --init-file <(echo "htop -u jack")
#!/bin/sh
lxterm -e bash --init-file <(echo "torguard")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment