summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/firestartx72
1 files changed, 43 insertions, 29 deletions
diff --git a/src/firestartx b/src/firestartx
index 636fc84..1129f9d 100755
--- a/src/firestartx
+++ b/src/firestartx
@@ -1,5 +1,10 @@
1#!/bin/bash 1#!/bin/bash
2 2
3if [ $# = 0 ]
4then
5 set -- firestart
6fi
7
3get_new_display() 8get_new_display()
4{ 9{
5 for ((n=1; n<99; ++n)) 10 for ((n=1; n<99; ++n))
@@ -15,44 +20,53 @@ get_new_display()
15 20
16get_new_display || exit 21get_new_display || exit
17 22
18if [ $# = 0 ] 23dpi=$(xrdb -query | sed -n -e 's/^Xft.dpi:[ \t]*//p')
19then
20 set -- firestart
21fi
22 24
23# TITLE=$* # lol, startx doesn't support arguments with spaces 25launch_xserver()
24TITLE=$1 26{
25TITLE= # blank title documents the screen grab keys in the title 27 "$@" -- "$(which Xephyr)" "$NEW_DISPLAY" \
28 -resizeable \
29 -p 0 \
30 -terminate \
31 ${dpi:+ -dpi "$dpi"}
32}
26 33
27if [ "$1" != firestart ] 34if [ "$1" != firestart ]
28then 35then
29 USE_XINIT=y
30fi
31
32if [ "$USE_XINIT" ]
33then
34 set -x
35 case "$1" in 36 case "$1" in
36 /*) ;; 37 */*)
37 *) f1=$(which "$1") || exit 38 [ -x "$1" ] || exit
38 shift 39 ;;
39 set -- "$f1" "$@" 40 *)
40 ;; 41 f1=$(command -v "$1") || exit
42 shift
43 set -- "$f1" "$@"
44 ;;
41 esac 45 esac
42 xinit "$@" -- $(which Xephyr) "$NEW_DISPLAY" -resizeable -p 0 -terminate ${TITLE:+ -title "$TITLE"} 46 launch_xserver xinit "$@"
43else 47else
44 set -x 48 XSESSION_IS_FIRESTARTX=
45 dpi=$(xrdb -query | sed -n -e 's/^Xft.dpi:[ \t]*//p') 49 if grep -qF XSESSION_IS_FIRESTARTX ~/.xsession
46 startx -- "$(which Xephyr)" "$NEW_DISPLAY" \
47 -resizeable \
48 -p 0 \
49 -terminate \
50 ${TITLE:+ -title "$TITLE"} \
51 ${dpi:+ -dpi "$dpi"} \
52 &
53 if [ $# -gt 0 ]
54 then 50 then
51 # Our xsession will launch firestartx along with i3, etc.
52 XSESSION_IS_FIRESTARTX=y launch_xserver startx ~/.xsession &
53 else
54 # We need to wait for xrdb to be run, or else firefox will
55 # disastrously start without the Xft.dpi setting. But we
56 # cannot poll on the setting forever since it might not exist
57 # in every configuration.
58 launch_xserver startx &
59 enable -f /usr/lib/bash/sleep >/dev/null 2>&1 || true
60 set -x
61 tries=0
62 while [ $tries -lt 40 ] &&
63 ! xrdb -display "$NEW_DISPLAY" -query | grep -q '^Xft.dpi:'
64 do
65 sleep 0.05
66 tries=$((tries + 1))
67 done
55 DISPLAY=$NEW_DISPLAY "$@" & 68 DISPLAY=$NEW_DISPLAY "$@" &
56 fi 69 fi
70
57 wait 71 wait
58fi 72fi