summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-29 06:30:25 -0400
committerDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-29 06:30:25 -0400
commit663764ea8b9e547d1e422a7e7a335415405945ab (patch)
treeaf98aa644e92709a370b555b004c6a60bbe2efd0 /src
parentc62679efab6b33db38beb6a21d057c3525e44f62 (diff)
normalize file locations
Diffstat (limited to 'src')
-rwxr-xr-xsrc/firefox-io-slayer (renamed from src/firefox-io-slayer-redux)0
-rwxr-xr-xsrc/firestart40
-rwxr-xr-xsrc/firestartx58
-rw-r--r--src/ioslay@.service3
4 files changed, 100 insertions, 1 deletions
diff --git a/src/firefox-io-slayer-redux b/src/firefox-io-slayer
index fe54e37..fe54e37 100755
--- a/src/firefox-io-slayer-redux
+++ b/src/firefox-io-slayer
diff --git a/src/firestart b/src/firestart
new file mode 100755
index 0000000..5cc1c92
--- /dev/null
+++ b/src/firestart
@@ -0,0 +1,40 @@
1#!/bin/bash
2
3UNIT=firefox@$DISPLAY
4
5if systemctl --user is-active "$UNIT" >/dev/null
6then
7 echo "Attemping to contact existing Firefox instance." >&2
8 # Ask the existing firefox to open a new window.
9
10 # Firefox does not include an official API to do this in a way that
11 # is not racy. If we merely do this:
12 #
13 # exec firefox "$@"
14 #
15 # ...then the unit could become inactive after our check, in which
16 # case this launches a new firefox outside the container!
17 #
18 # So instead, we launch the same command using a systemd container
19 # that prevents Firefox from forking off a new process.
20 #
21 # Well, actually, we let it fork off _one_ process, since otherwise
22 # it segfaults. But this _does_ happen to prevent it starting a new
23 # firefox instance! Firefox safely segfaults if it is limited this
24 # way while trying to start a new instance.
25 #
26 # A more "correct" approach is available here:
27 # https://github.com/ayosec/findfox
28 exec systemd-run \
29 --user \
30 --property Environment="DISPLAY=$DISPLAY" \
31 --property Environment=XAUTHORITY="$XAUTHORITY" \
32 --property TasksMax=2 \
33 --wait \
34 --pipe \
35 -q \
36 -- /bin/sh -c 'exec firefox "$@"' sh "$@"
37else
38 systemctl --user reset-failed "$UNIT" 2>/dev/null
39 systemctl --user start "$UNIT"
40fi
diff --git a/src/firestartx b/src/firestartx
new file mode 100755
index 0000000..636fc84
--- /dev/null
+++ b/src/firestartx
@@ -0,0 +1,58 @@
1#!/bin/bash
2
3get_new_display()
4{
5 for ((n=1; n<99; ++n))
6 do
7 if [ ! -e /tmp/.X$n-lock ]
8 then
9 NEW_DISPLAY=:$n
10 return
11 fi
12 done
13 false
14}
15
16get_new_display || exit
17
18if [ $# = 0 ]
19then
20 set -- firestart
21fi
22
23# TITLE=$* # lol, startx doesn't support arguments with spaces
24TITLE=$1
25TITLE= # blank title documents the screen grab keys in the title
26
27if [ "$1" != firestart ]
28then
29 USE_XINIT=y
30fi
31
32if [ "$USE_XINIT" ]
33then
34 set -x
35 case "$1" in
36 /*) ;;
37 *) f1=$(which "$1") || exit
38 shift
39 set -- "$f1" "$@"
40 ;;
41 esac
42 xinit "$@" -- $(which Xephyr) "$NEW_DISPLAY" -resizeable -p 0 -terminate ${TITLE:+ -title "$TITLE"}
43else
44 set -x
45 dpi=$(xrdb -query | sed -n -e 's/^Xft.dpi:[ \t]*//p')
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
55 DISPLAY=$NEW_DISPLAY "$@" &
56 fi
57 wait
58fi
diff --git a/src/ioslay@.service b/src/ioslay@.service
index 1a00bd4..11db192 100644
--- a/src/ioslay@.service
+++ b/src/ioslay@.service
@@ -1,5 +1,6 @@
1[Unit] 1[Unit]
2Description = Kill firefox when it spins the disk 2Description = Kill firefox when it spins the disk
3Requires = firefox@%I
3 4
4[Service] 5[Service]
5ExecStart = /usr/local/bin/firefox-io-slayer-redux %I 6ExecStart = /usr/local/bin/firefox-io-slayer %I