#!/bin/bash # Drückt den ersten sichtbaren St.Button mit diesem Text (in der Extension oder in Dialogen): dev/press.sh "Text" DIR=$(cd "$(dirname "$0")" && pwd) "$DIR/eval.sh" " const St = imports.gi.St; const wanted = $(printf '%s' "$1" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))'); const text = a => a.label ?? a.child?.text ?? a.get_child?.()?.text ?? ''; function find(actor) { if (!actor.visible) return null; if (actor instanceof St.Button && text(actor) === wanted) return actor; for (const c of actor.get_children()) { const r = find(c); if (r) return r; } return null; } const root = Main.extensionManager.lookup('desktop@marha.de').stateObj._root; const b = find(Main.layoutManager.modalDialogGroup) ?? find(root); if (!b) throw new Error('kein Button: ' + wanted); const [x, y] = b.get_transformed_position(); b.emit('clicked', 1); 'pressed ' + wanted + ' @ ' + Math.round(x + b.width / 2) + ',' + Math.round(y + b.height / 2); "