From 97cc19053316addd4c105d33a60a7e9edcc1e1b5 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Thu, 4 Nov 2021 11:40:14 +0100 Subject: [PATCH] Initial commit --- raisewindow | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 raisewindow diff --git a/raisewindow b/raisewindow new file mode 100644 index 0000000..9e228f8 --- /dev/null +++ b/raisewindow @@ -0,0 +1,39 @@ +#!/bin/bash + +#!/bin/bash + +# usage: +# raisewindow firefox +# +# or, if the binary and window class are dissimilar: +# raisewindow firefox-developer firefox +# ^binary name ^ partial class name of windows created by this application (xprop) + +CMD=$1 + +if [ -n "$2" ]; then + CLASS=$2 +else + CLASS=$CMD +fi + +function gshell(){ + gdbus call \ + --session \ + --dest org.gnome.Shell \ + --object-path /org/gnome/Shell \ + --method org.gnome.Shell.Eval "$1" \ + | sed -E -e "s/^\(\S+, '//" -e "s/'\)$//" +} + +if [[ $XDG_SESSION_TYPE = "wayland" ]]; then + RESP=`gshell " + global + .get_window_actors() + .filter(w=>w.meta_window.get_wm_class().toLowerCase()==\"$CLASS\".toLowerCase())[0].meta_window.activate(0)"` + if [[ "$RESP" == *undefined ]]; then + $CMD; + fi +else + wmctrl -x -a "$CLASS" || ($CMD & notify-send -i "$CLASS" "Starting $CMD"); +fi