blob: 4bb2d70aa4071c7635b59c65509f499c5fddfe9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/sh
window="LibreWolf"
running() { windows=$(wmctrl -l)
test "${windows#*"$window"}" != "$windows"; }
press() { sleep 0.1; xdotool keyup Super
xdotool key --clearmodifiers "$@"; }
if ! running; then
notify-send "Starting $window..."
start="$(date +%s.%3N)"
setsid -f librewolf -P "${FFPROFILE:-default-release}"
for _ in $(seq 1000); do sleep 0.1; running && break; done
end="$(date +%s.%3N)"
time="$(echo "$end - $start" | bc)"
notify-send "$window" "Started in ${time}s"
started=1
fi
wmctrl -a "$window" ||
{ notify-send "ffbrowser" "ERROR: librewolf window not found"; exit 1; }
[ "$started" = 1 ] || press ctrl+t
query="$*"
if [ "$query" != "${query#http*://}" ]; then
press ctrl+l
elif [ -e "$query" ]; then
query="$(readlink -f "$query")"; press ctrl+l
else
# workaround for ctrl+k not working at initial startup
[ "$started" = 1 ] && sleep 0.5
press ctrl+k
fi
if [ -n "$query" ]; then
xdotool type "$query"
press Return
fi
|