From 5c916d69d457101326803eb076a746060e3618cf Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Thu, 21 Nov 2024 13:30:52 +0530 Subject: Moved from github --- .local/bin/desktop/librewolf-open | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 .local/bin/desktop/librewolf-open (limited to '.local/bin/desktop/librewolf-open') diff --git a/.local/bin/desktop/librewolf-open b/.local/bin/desktop/librewolf-open new file mode 100755 index 0000000..4bb2d70 --- /dev/null +++ b/.local/bin/desktop/librewolf-open @@ -0,0 +1,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 + -- cgit v1.2.3