Skip to content

Commit

Permalink
Add Bash script for creating windows on i3 startup
Browse files Browse the repository at this point in the history
There's still an issue with starting screen in detached mode (with
`screen -d -m`) and starting xterms that immediately attach (like the
script does) on my system: backspace and ^H misbehave and erase all
characters before the cursor in those xterms.
  • Loading branch information
meribold committed Feb 29, 2016
1 parent 9dec268 commit 03a7049
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 1 addition & 4 deletions config/i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ gaps outer -22
smart_gaps on
# }}}1

exec --no-startup-id "i3-msg 'append_layout ~/.config/i3/scratchpad.json; move scratchpad'"
exec --no-startup-id "xterm -e 'screen -x || screen'"
exec --no-startup-id "i3-msg 'append_layout ~/.config/i3/workspace-2.json; move workspace 2'"
exec --no-startup-id "xterm -e 'screen -x'"
exec --no-startup-id ~/dotfiles/config/i3/startup.sh

# vim: tw=90 sts=-1 sw=3 et fdm=marker
24 changes: 24 additions & 0 deletions config/i3/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

i3-msg 'append_layout ~/.config/i3/scratchpad.json; move scratchpad'
i3-msg 'append_layout ~/.config/i3/workspace-2.json; move workspace 2'

if ! screen -ls; then
# There's no screen session; create one.
screen -d -m
while ! screen -ls; do sleep .1; done
# Create some new windows inside the screen session.
screen -X screen && screen -X screen && screen -X 'select' 0
fi

# Disable XON/XOFF flow control before attaching. I need to do this when the screen
# session was started in detached mode and I'm starting a new xterm that immediately
# attaches. I don't understand why.
# Note: using `screen -r` for one xterm if we just created a detached session doesn't
# always work because either xterm may attach first (`screen -r` won't attach to a session
# that is already attached somewhere else). Contrary to what the screen(1) man page says,
# `screen -x` still works when the screen session is detached.
xterm -e 'stty -ixon && screen -x' &
xterm -e 'stty -ixon && screen -x' &

# vim: tw=90 sts=-1 sw=3 et

0 comments on commit 03a7049

Please sign in to comment.