Sun, 15 Jun 2014 11:25:55 -0400
copy auto-start from default
1 | 1 | #! /bin/sh |
2 | ||
3 | # Simple autostart file for i3-wm, you can execute it from i3 config with | |
4 | # exec $HOME/bin/auto-start-for-i3 | |
5 | # | |
46 | 6 | # xdotool and notify-send must be installed. On BSD use jot instead of |
1 | 7 | # seq or install seq from ports. |
8 | ||
9 | ||
10 | # Max seconds to wait until the process is up | |
11 | MAXWAIT=10 | |
12 | ||
13 | # Start the given command and wait until it's visible | |
14 | StartProg() | |
15 | { | |
16 | "$@" & # Handle arguments with whitspaces | |
17 | mypid=$! # Pid of last background process | |
18 | echo "Waiting on ${mypid}: $@" | |
19 | for i in `seq $MAXWAIT` # count from 1 to MAXWAIT | |
20 | do | |
21 | if xdotool search --onlyvisible --pid $mypid; then | |
22 | return 0 | |
23 | fi | |
24 | sleep 1 | |
25 | done | |
46 | 26 | notify-send "Error on executing: $@" |
1 | 27 | } |
28 | ||
29 | StartProgName() | |
30 | { | |
31 | "$@" & # Handle arguments with whitspaces | |
32 | mypid=$! # Pid of last background process | |
33 | echo "Waiting on $1: $@" | |
34 | for i in `seq $MAXWAIT` # count from 1 to MAXWAIT | |
35 | do | |
36 | if xdotool search --onlyvisible --name $1; then | |
37 | return 0 | |
38 | fi | |
39 | sleep 1 | |
40 | done | |
46 | 41 | notify-send "Error on executing: $@" |
1 | 42 | } |
43 | ||
59
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
44 | WaitProgName() |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
45 | { |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
46 | echo "Waiting on $1" |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
47 | for i in `seq $MAXWAIT` # count from 1 to MAXWAIT |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
48 | do |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
49 | if xdotool search --onlyvisible --name $1; then |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
50 | return 0 |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
51 | fi |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
52 | sleep 1 |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
53 | done |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
54 | notify-send "Error waiting on $1: $@" |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
55 | } |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
56 | |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
57 | WaitClassName() |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
58 | { |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
59 | echo "Waiting on window class $1" |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
60 | for i in `seq $MAXWAIT` # count from 1 to MAXWAIT |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
61 | do |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
62 | if xdotool search --onlyvisible --class $1; then |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
63 | return 0 |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
64 | fi |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
65 | sleep 1 |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
66 | done |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
67 | notify-send "Error waiting on $1: $@" |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
68 | } |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
69 | |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
70 | |
1 | 71 | # ### --- emacs --- ### |
72 | # StartProg emacs | |
73 | # | |
74 | # ### --- ding ---- ### | |
75 | # StartProg ding | |
76 | # i3-msg border none | |
77 | # | |
78 | # # make right half bigger | |
79 | # i3-msg resize grow left 16 px or 16 ppt | |
80 | # | |
81 | # # build container | |
82 | # i3-msg split v | |
83 | # sleep 1 | |
84 | # | |
85 | # ### --- terminal --- ### | |
86 | # StartProg rxvt | |
87 | # | |
88 | # # Make Terminal bigger and Ding smaller | |
89 | # i3-msg resize grow up 32 px or 32 ppt | |
90 | # | |
91 | # ### --------------------------------- tab START--- ### | |
92 | # ### ---------------------------------------------- ### | |
93 | # i3-msg split v | |
94 | # i3-msg layout tabbed | |
95 | # | |
96 | # ### --- gnome-commander --- ### | |
97 | # StartProg gnome-commander | |
98 | # | |
99 | # ### --- chromium --- ### | |
100 | # StartProg chromium | |
101 | # | |
102 | # ### --- pdf --- ### | |
103 | # StartProg evince "~/Dokumente/Haskell/Haskell.pdf" | |
104 | # ### ---------------------------------------------- ### | |
105 | # ### ---------------------------------- tab END --- ### | |
106 | # | |
107 | # ### --- new terminal left under emacs --- ### | |
108 | # i3-msg focus left | |
109 | # i3-msg split v | |
110 | # StartProg rxvt | |
111 | # | |
112 | # # terminal without border and make it smaller | |
113 | # i3-msg border none | |
114 | # i3-msg resize shrink up 32 px or 32 ppt | |
115 | # | |
116 | ||
59
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
117 | # StartProg urxvt |
34
33bdbdb9ec90
Make dedicated workspace for Mail
Meredith Howard <mhoward@roomag.org>
parents:
23
diff
changeset
|
118 | # i3-msg 'split h' |
33bdbdb9ec90
Make dedicated workspace for Mail
Meredith Howard <mhoward@roomag.org>
parents:
23
diff
changeset
|
119 | # StartProgName gvim |
23
a61d6f99a162
Create branch mhoward-lt for host-specific stuff
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
120 | # i3-msg 'focus left; split v' |
59
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
121 | # StartProg urxvt |
23
a61d6f99a162
Create branch mhoward-lt for host-specific stuff
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
122 | # i3-msg 'resize shrink height 20 px or 20 ppt' |
1 | 123 | |
59
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
124 | if [ -r ~/.i3/auto-start.local ]; then |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
125 | . .i3/auto-start.local |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
126 | fi |
7171e2a98c17
copy auto-start from default
Meredith Howard <mhoward@roomag.org>
parents:
58
diff
changeset
|
127 | |
1 | 128 | exit 0 |