.i3/auto-start

changeset 377
7190350f2ab3
parent 55
fe505cd6be19
child 821
013f5efa8f2d
equal deleted inserted replaced
376:45be44be97c5 377:7190350f2ab3
1 #! /bin/sh 1 #!/bin/sh
2
3 # Simple autostart file for i3-wm, you can execute it from i3 config with 2 # Simple autostart file for i3-wm, you can execute it from i3 config with
4 # exec $HOME/bin/auto-start-for-i3 3 # exec $HOME/.i3/auto-start
5 # 4 #
6 # xdotool and notify-send must be installed. On BSD use jot instead of 5 # xdotool and notify-send must be installed. On BSD use jot instead of
7 # seq or install seq from ports. 6 # seq or install seq from ports.
8
9 7
10 # Max seconds to wait until the process is up 8 # Max seconds to wait until the process is up
11 MAXWAIT=10 9 MAXWAIT=10
12 10
13 # Start the given command and wait until it's visible 11 # Start the given command and wait until it's visible
14 StartProg() 12 StartProg()
15 { 13 {
16 "$@" & # Handle arguments with whitspaces 14 "$@" & # Handle arguments with whitspaces
17 mypid=$! # Pid of last background process 15 mypid=$! # Pid of last background process
18 echo "Waiting on ${mypid}: $@" 16 echo "Waiting on ${mypid}: $@"
19 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT 17 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT
20 do 18 do
21 if xdotool search --onlyvisible --pid $mypid; then 19 if xdotool search --onlyvisible --pid $mypid; then
22 return 0 20 return 0
23 fi 21 fi
24 sleep 1 22 sleep 1
25 done 23 done
26 notify-send "Error on executing: $@" 24 notify-send "Error on executing: $@"
27 } 25 }
28 26
29 StartProgName() 27 StartProgName()
30 { 28 {
31 "$@" & # Handle arguments with whitspaces 29 "$@" & # Handle arguments with whitspaces
32 mypid=$! # Pid of last background process 30 mypid=$! # Pid of last background process
33 echo "Waiting on $1: $@" 31 echo "Waiting on $1: $@"
34 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT 32 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT
35 do 33 do
36 if xdotool search --onlyvisible --name $1; then 34 if xdotool search --onlyvisible --name $1; then
37 return 0 35 return 0
38 fi 36 fi
39 sleep 1 37 sleep 1
40 done 38 done
41 notify-send "Error on executing: $@" 39 notify-send "Error on executing: $@"
42 } 40 }
43 41
44 WaitProgName() 42 WaitProgName()
45 { 43 {
46 echo "Waiting on $1" 44 echo "Waiting on $1"
47 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT 45 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT
48 do 46 do
49 if xdotool search --onlyvisible --name $1; then 47 if xdotool search --onlyvisible --name $1; then
50 return 0 48 return 0
51 fi 49 fi
52 sleep 1 50 sleep 1
53 done 51 done
54 notify-send "Error waiting on $1: $@" 52 notify-send "Error waiting on $1: $@"
55 } 53 }
56 54
57 WaitClassName() 55 WaitClassName()
58 { 56 {
59 echo "Waiting on window class $1" 57 echo "Waiting on window class $1"
60 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT 58 for i in `seq $MAXWAIT` # count from 1 to MAXWAIT
61 do 59 do
62 if xdotool search --onlyvisible --class $1; then 60 if xdotool search --onlyvisible --class $1; then
63 return 0 61 return 0
64 fi 62 fi
65 sleep 1 63 sleep 1
66 done 64 done
67 notify-send "Error waiting on $1: $@" 65 notify-send "Error waiting on $1: $@"
68 } 66 }
69 67
70 68
71 # ### --- emacs --- ### 69 # ### --- emacs --- ###
72 # StartProg emacs 70 # StartProg emacs

mercurial