From 2a6196f649b184201fd06d46fae8bc2c6dbdb818 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 6 Jan 2024 22:31:35 +0100 Subject: [PATCH 01/10] Allow printing circular objects --- utils.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index 8b7aca617..586a707db 100644 --- a/utils.js +++ b/utils.js @@ -45,12 +45,32 @@ export function print_stacktrace(error) { console.error(`JS ERROR: ${error}\n ${trace.join('\n')}`); } +// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value +function getCircularReplacer() { + const ancestors = []; + return function (key, value) { + if (typeof value !== "object" || value === null) { + return value; + } + // `this` is the object that value is contained in, + // i.e., its direct parent. + while (ancestors.length > 0 && ancestors.at(-1) !== this) { + ancestors.pop(); + } + if (ancestors.includes(value)) { + return "[Circular]"; + } + ancestors.push(value); + return value; + }; +} + /** * Pretty prints args using JSON.stringify. * @param {...any} arugs */ export function prettyPrintToLog(...args) { - console.log(args.map(v => JSON.stringify(v, null), 2)); + console.log(args.map(v => JSON.stringify(v, getCircularReplacer()), 2)); } export function framestr(rect) { From d1e399f3598593bdf1e2957cb8c56f80b71d3e04 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 6 Jan 2024 22:32:05 +0100 Subject: [PATCH 02/10] Avoid error if column is not found --- tiling.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tiling.js b/tiling.js index ffe22f631..ad91608df 100644 --- a/tiling.js +++ b/tiling.js @@ -1050,6 +1050,9 @@ export class Space extends Array { rowOf(metaWindow) { let column = this[this.indexOf(metaWindow)]; + if (column === undefined) { + return -1; + } return column.indexOf(metaWindow); } From 2a262f6f7e503c42be1b802dcd4c6d6d5eb9b644 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 6 Jan 2024 22:32:40 +0100 Subject: [PATCH 03/10] Add getter for keybinding names --- keybindings.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keybindings.js b/keybindings.js index c6dc7f621..a1fbaefab 100644 --- a/keybindings.js +++ b/keybindings.js @@ -272,6 +272,10 @@ export function byMutterName(name) { return nameMap[name]; } +export function getAllMutterNames() { + return Object.keys(nameMap); +} + export function byId(mutterId) { return actionIdMap[mutterId]; } From cb05486e7e0a686c91893a0b3cc55b528880aebc Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 6 Jan 2024 22:32:50 +0100 Subject: [PATCH 04/10] Emit signal on first window frame --- tiling.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tiling.js b/tiling.js index ad91608df..9f33ef537 100644 --- a/tiling.js +++ b/tiling.js @@ -2858,6 +2858,7 @@ export const Spaces = class Spaces extends Map { signals.connectOneShot(actor, 'first-frame', () => { allocateClone(metaWindow); insertWindow(metaWindow, { existing: false }); + this.emit("window-first-frame", metaWindow); }); } From f5ec973b47b9feb102d741528cbc8bee20711945 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 6 Jan 2024 22:35:01 +0100 Subject: [PATCH 05/10] Initial draft of dbus interface --- dbus.js | 270 ++++++++++++++++++++++++++++++ dbus/org.github.PaperWM.Space.xml | 9 + dbus/org.github.PaperWM.xml | 52 ++++++ extension.js | 4 +- imports.js | 1 + 5 files changed, 334 insertions(+), 2 deletions(-) create mode 100644 dbus.js create mode 100644 dbus/org.github.PaperWM.Space.xml create mode 100644 dbus/org.github.PaperWM.xml diff --git a/dbus.js b/dbus.js new file mode 100644 index 000000000..f2eb390c3 --- /dev/null +++ b/dbus.js @@ -0,0 +1,270 @@ +// Ressources: +// - https://gjs.guide/guides/gio/dbus.html#introduction-to-d-bus +// - https://dbus.freedesktop.org/doc/dbus-api-design.html +// - https://gitlab.gnome.org/GNOME/gnome-shell/-/tree/main/data/dbus-interfaces +// - https://gjs-docs.gnome.org/gio20~2.0/gio.bus_own_name +// - https://docs.gtk.org/glib/gvariant-format-strings.html (dbus does not support maybe/nullable types) +// - https://docs.gtk.org/glib/gvariant-text.html +// - https://dbus.freedesktop.org/doc/dbus-specification.html +// - https://dbus.freedesktop.org/doc/dbus-specification.html#type-system +// - https://www.baeldung.com/linux/dbus +// - D-Spy, dbus-monitor, dbus-send + +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; + +import { Tiling, Keybindings, Utils } from './imports.js'; +import * as Imports from './imports.js'; + +// used as the well known name and as the interface name in DBus +const DBUS_NAME = "org.github.PaperWM"; +const DBUS_PATH = "/org/github/PaperWM" +const DBUS_INTERFACE_DIR = "./dbus"; + +let serviceInstance = null; +let spaceInstances = null; +let dbusConnection = null; +let dbusOwnerId; + +export function enable() { + console.debug(`#PaperWM: Registering DBus interface: ${DBUS_NAME} on path ${DBUS_PATH}`); + try { + dbusOwnerId = Gio.bus_own_name( + Gio.BusType.SESSION, + DBUS_NAME, + Gio.BusNameOwnerFlags.DO_NOT_QUEUE, + onBusAcquired, + onNameAcquired, + null, + ); + console.debug(`#PaperWM: dbusOwnerId=${dbusOwnerId}`); + } catch (e) { + console.error("#PaperWM: Failed to own DBus name.") + console.error(e); + } +} + +export function disable() { + try { + Gio.bus_unown_name(dbusOwnerId); + } catch (e) { + console.error("#PaperWM: Failed to unown DBus name.") + console.error(e); + } + + dbusConnection = null; + serviceInstance.destroy(); + serviceInstance = null; + spaceInstances = null; +} + +/** + * Invoked when a connection to a message bus has been obtained. + * + * If there is a client waiting for the well-known name to appear on the bus, + * you probably want to export your interfaces here. This way the interfaces + * are ready to be used when the client is notified the name has been owned. + * + * @param {Gio.DBusConnection} connection - the connection to a message bus + * @param {string} name - the name that is requested to be owned + */ +function onBusAcquired(connection, name) { + console.log(`${name}: connection acquired`); + dbusConnection = connection; + console.log(connection); + + serviceInstance = new PaperWMService(); + exportDBusObject("org.github.PaperWM", serviceInstance, DBUS_PATH); + + spaceInstances = new Map(); + for (const key of Tiling.spaces.keys()) { + const i = key.index(); + spaceInstances[i] = new DBusSpace(i); + exportDBusObject("org.github.PaperWM.Space", spaceInstances[i], DBUS_PATH + "/spaces/" + i); + } +} + +function exportDBusObject(interfaceName, object, dbusPath) { + const xmlPath = DBUS_INTERFACE_DIR + "/" + interfaceName + ".xml"; + const uri = GLib.uri_resolve_relative(import.meta.url, xmlPath, GLib.UriFlags.NONE); + const file = Gio.File.new_for_uri(uri); + const [success, xmlContent, _etag] = file.load_contents(null); + if (!success) { + throw Error("Failed to read dbus interface definition from xml file."); + } + const xmlString = new TextDecoder("utf-8").decode(xmlContent); + + // Create the class instance, then the D-Bus object + const exportedObject = Gio.DBusExportedObject.wrapJSObject(xmlString, object); + + // Assign the exported object to the property the class expects, then export + object._impl = exportedObject; + exportedObject.export(dbusConnection, dbusPath); +} + +/** + * Invoked when the name is acquired. + * + * On the other hand, if you were using something like GDBusObjectManager to + * watch for interfaces, you could export your interfaces here. + * + * @param {Gio.DBusConnection} connection - the connection that acquired the name + * @param {string} name - the name being owned + */ +function onNameAcquired(connection, name) { + console.log(`${name}: name acquired`); + // TODO maybe use Gio.DBusObjectManager here +} + +class DBusSpace { + // NOTE: this._impl is set to the exported DBus service before any of the + // methods are called. + + constructor(i) { + this.i = i; + } + + space() { + return Tiling.spaces.spaceOfIndex(this.i); + } + + // Properties + get Name() { + return GLib.Variant.new_string(this.space().name); + } + + // Methods + Activate() { + console.log(`DBusSpace(${this.i}).Activate() invoked`); + this.space().activate(); + } +} + + +class PaperWMService { + // NOTE: this._impl is set to the exported DBus service before any of the + // methods are called. + + constructor() { + this.undos = new Array(); + + this.signals = new Utils.Signals(); + + // Need to use this signal as space::window-added does not contain + // e.g. wm_class. + this.signals.connect( + Tiling.spaces, "window-first-frame", + (_spaces, metaWindow) => { + const space = Tiling.spaces.spaceOfWindow(metaWindow); + this._impl.emit_signal('WindowAdded', + new GLib.Variant('(ssiiibbbb)', [ + metaWindow.wm_class ?? "", + metaWindow.title ?? "", + space.index ?? -1, + space.indexOf(metaWindow) ?? -1, + space.rowOf(metaWindow) ?? -1, + Tiling.isFloating(metaWindow), + Tiling.isScratch(metaWindow), + Tiling.isTransient(metaWindow), + Tiling.isTiled(metaWindow), + ])); + } + ); + } + + destroy() { + this.signals.destroy(); + } + + // Properties + get ReadOnlyProperty() { + return GLib.Variant.new_string('a string'); + } + + get ReadWriteProperty() { + if (this._readWriteProperty === undefined) + return false; + + return this._readWriteProperty; + } + + set ReadWriteProperty(value) { + if (this._readWriteProperty === value) + return; + + this._readWriteProperty = value; + this._impl.emit_property_changed('ReadWriteProperty', + GLib.Variant.new_boolean(this.ReadWriteProperty)); + } + + // Methods + ListSpaces() { + return spaceInstances.entries().map((index, space) => `/org/github/PaperWM/spaces/${index}`); + } + + ListActions() { + return Keybindings.getAllMutterNames(); + } + + TriggerAction(name) { + const action = Keybindings.byMutterName(name); + const binding = { + get_name: () => name, + get_mask: () => 0, + is_reversed: () => false, + }; + action.keyHandler(global.display, global.display.get_focus_window(), binding); + } + + /** + * Eval `input` as a function. + * + * If the function returns a functions it will be registered and can later be + * called using `UndoEval`. If the function returns something else it will + * be returned as a string. Most likely you want to manually create a string + * to get the correct representation. + * + * Usage (over DBus): + * + * ``` + * const [undoId, _output] = Eval('console.log("hi"); global.x = 1; () => { global.x = undefined; };'); + * UndoEval(undoId); + * + * const [_undoId, output] = Eval('console.log("hi"); global.x = 1; return "something";'); + * // assert output == "something"; + * ``` + */ + Eval(input) { + console.debug(`Service.Eval() invoked with '${input}'`); + + const f = new Function(input); + const undoF = f(Imports); + const undoIndex = this.undos.length; + if (typeof undoF === "function") { + this.undos.push(undoF); + return new GLib.Variant("(is)", [undoIndex, ""]); + } else { + this.undos.push(null); + return new GLib.Variant("(is)", [undoIndex, undoF]); + } + } + + UndoEval(undoId) { + if (undoId >= this.undos.length) { + throw new Error("Invalid undoId."); + } + const undoF = this.undos[undoId]; + if (undoF === null) { + // already used or no undo function registered + throw new Error("Invalid undoId."); + } + undoF(); + this.undos[undoId] = null; + } + + // Signals + emitTestSignal(value) { + this._impl.emit_signal('TestSignal', + new GLib.Variant('(sb)', [value, true])); + } +} diff --git a/dbus/org.github.PaperWM.Space.xml b/dbus/org.github.PaperWM.Space.xml new file mode 100644 index 000000000..403ef0169 --- /dev/null +++ b/dbus/org.github.PaperWM.Space.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/dbus/org.github.PaperWM.xml b/dbus/org.github.PaperWM.xml new file mode 100644 index 000000000..b521d62bf --- /dev/null +++ b/dbus/org.github.PaperWM.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extension.js b/extension.js index 91164d2dc..34cbfdcc8 100644 --- a/extension.js +++ b/extension.js @@ -8,7 +8,7 @@ import * as Util from 'resource:///org/gnome/shell/misc/util.js'; import { Utils, Settings, Gestures, Keybindings, LiveAltTab, Navigator, - Stackoverlay, Scratch, Workspace, Tiling, Topbar, Patches, App + Stackoverlay, Scratch, Workspace, Tiling, Topbar, Patches, App, DBus } from './imports.js'; import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'; @@ -50,7 +50,7 @@ export default class PaperWM extends Extension { modules = [ Utils, Settings, Patches, Gestures, Keybindings, LiveAltTab, Navigator, Stackoverlay, Scratch, - Workspace, Tiling, Topbar, App, + Workspace, Tiling, Topbar, App, DBus ]; #userStylesheet = null; diff --git a/imports.js b/imports.js index 7bf7ec927..b79342f0a 100644 --- a/imports.js +++ b/imports.js @@ -16,3 +16,4 @@ export * as Tiling from './tiling.js'; export * as Topbar from './topbar.js'; export * as Utils from './utils.js'; export * as Workspace from './workspace.js'; +export * as DBus from './dbus.js'; From d715736f665bf7a939f848b68baa4299bbccad61 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 6 Jan 2024 22:35:18 +0100 Subject: [PATCH 06/10] Convenience scripts to test dbus --- dbus-send.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.sh | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100755 dbus-send.sh create mode 100755 monitor.sh diff --git a/dbus-send.sh b/dbus-send.sh new file mode 100755 index 000000000..d9ba87ce7 --- /dev/null +++ b/dbus-send.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# +# Usage: +# + +set -euo pipefail + +main() { + while [[ $# -gt 0 ]]; do + case "$1" in + action) + shift + trigger_action "$1" + return + ;; + list-actions) + shift + list_actions + return + ;; + esac + done +} + +trigger_action() { + METHOD=TriggerAction call "string:$1" +} + +list_actions() { + local result + result=$(METHOD=ListActions call) + while IFS=' ' read -ra words; do + for word in "${words[@]}"; do + case "${word}" in + array|\[|\]) + ;; + *) + echo "${word}" + ;; + esac + done + done <<< "$result" +} + +send() { + local args + args=( --dest=org.github.PaperWM ) + if [[ -n "${OPTIONS:-}" ]]; then + args+=( "${OPTIONS}" ) + fi + args+=( + /org/github/PaperWM + "org.github.PaperWM.${METHOD}" + "$@" + ) + + set -x + dbus-send "${args[@]}" + { set +x; } &> /dev/null +} + +call() { + OPTIONS=--print-reply=literal send "$@" +} + +global_rematch() { + local s=$1 regex=$2 + while [[ $s =~ $regex ]]; do + echo "${BASH_REMATCH[1]}" + s=${s#*"${BASH_REMATCH[1]}"} + done +} + +join_by() { + local IFS="$1" + shift + echo "$*" +} + +main "$@" diff --git a/monitor.sh b/monitor.sh new file mode 100755 index 000000000..d0a33b152 --- /dev/null +++ b/monitor.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# Usage: +# monitor.sh +# monitor.sh --profile # table like tab separated output +# monitor.sh --signals # only show signals +# monitor.sh FILTER # see https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules +# monitor.sh type=signal + +set -euo pipefail + +ADDITIONAL_ARGS=() +FILTER=("path=/org/github/PaperWM") + +main() { + while [[ $# -gt 0 ]]; do + case "$1" in + --profile) + ADDITIONAL_ARGS+=( --profile ) + shift + ;; + --signals) + FILTER+=( "type=signal" ) + shift + ;; + --*) + ADDITIONAL_ARGS+=( "$1" ) + shift + ;; + *) + FILTER+=( "$1" ) + shift + ;; + esac + done + + local filter args + filter=$(join_by "," "${FILTER[@]}") + args=( "${ADDITIONAL_ARGS[@]}" ) + args+=( "${filter}" ) + + { set -x; dbus-monitor "${args[@]}"; { set +x; } &>/dev/null; } | tail -n +5 +} + +join_by() { + local IFS="$1" + shift + echo "$*" +} + +main "$@" From a3cd6bfca2e878f27d4b453a47eb894348ed4039 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sun, 7 Jan 2024 17:50:23 +0100 Subject: [PATCH 07/10] Move spaces functions to same interface --- dbus.js | 70 +++++++++++++++---------------- dbus/org.github.PaperWM.Space.xml | 9 ---- dbus/org.github.PaperWM.xml | 15 ++++++- 3 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 dbus/org.github.PaperWM.Space.xml diff --git a/dbus.js b/dbus.js index f2eb390c3..b94f3444a 100644 --- a/dbus.js +++ b/dbus.js @@ -22,7 +22,6 @@ const DBUS_PATH = "/org/github/PaperWM" const DBUS_INTERFACE_DIR = "./dbus"; let serviceInstance = null; -let spaceInstances = null; let dbusConnection = null; let dbusOwnerId; @@ -55,7 +54,6 @@ export function disable() { dbusConnection = null; serviceInstance.destroy(); serviceInstance = null; - spaceInstances = null; } /** @@ -75,13 +73,6 @@ function onBusAcquired(connection, name) { serviceInstance = new PaperWMService(); exportDBusObject("org.github.PaperWM", serviceInstance, DBUS_PATH); - - spaceInstances = new Map(); - for (const key of Tiling.spaces.keys()) { - const i = key.index(); - spaceInstances[i] = new DBusSpace(i); - exportDBusObject("org.github.PaperWM.Space", spaceInstances[i], DBUS_PATH + "/spaces/" + i); - } } function exportDBusObject(interfaceName, object, dbusPath) { @@ -112,32 +103,7 @@ function exportDBusObject(interfaceName, object, dbusPath) { * @param {string} name - the name being owned */ function onNameAcquired(connection, name) { - console.log(`${name}: name acquired`); - // TODO maybe use Gio.DBusObjectManager here -} - -class DBusSpace { - // NOTE: this._impl is set to the exported DBus service before any of the - // methods are called. - - constructor(i) { - this.i = i; - } - - space() { - return Tiling.spaces.spaceOfIndex(this.i); - } - - // Properties - get Name() { - return GLib.Variant.new_string(this.space().name); - } - - // Methods - Activate() { - console.log(`DBusSpace(${this.i}).Activate() invoked`); - this.space().activate(); - } + // console.log(`${name}: name acquired`); } @@ -197,11 +163,20 @@ class PaperWMService { GLib.Variant.new_boolean(this.ReadWriteProperty)); } - // Methods + // Spaces ListSpaces() { - return spaceInstances.entries().map((index, space) => `/org/github/PaperWM/spaces/${index}`); + return [...Tiling.spaces.values()].map(ws => encode_space(ws)); + } + + GetSpace(index) { + return encode_space(get_space(index)); + } + + ActivateSpace(index) { + get_space(index).activate(); } + // Actions ListActions() { return Keybindings.getAllMutterNames(); } @@ -268,3 +243,24 @@ class PaperWMService { new GLib.Variant('(sb)', [value, true])); } } + + +function encode_space(ws) { + console.log(typeof ws); + console.log(ws.constructor.name); + Utils.prettyPrintToLog(ws); + const out = { + index: ws.index, + name: ws.name, + // TODO more useful information + }; + return JSON.stringify(out); +} + +function get_space(index) { + const ws = Tiling.spaces.spaceOfIndex(index); + if (ws === undefined) { + throw new Error(`No space with index ${index}`); + } + return ws; +} diff --git a/dbus/org.github.PaperWM.Space.xml b/dbus/org.github.PaperWM.Space.xml deleted file mode 100644 index 403ef0169..000000000 --- a/dbus/org.github.PaperWM.Space.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/dbus/org.github.PaperWM.xml b/dbus/org.github.PaperWM.xml index b521d62bf..e067460bd 100644 --- a/dbus/org.github.PaperWM.xml +++ b/dbus/org.github.PaperWM.xml @@ -12,10 +12,21 @@ + + - + + + + + + + + + + @@ -24,6 +35,7 @@ + @@ -46,6 +58,7 @@ + From 8bfc343b6864bc1136d80387e41620d152de9b58 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Mon, 8 Jan 2024 20:04:57 +0100 Subject: [PATCH 08/10] Change signal to json and define trace property --- dbus.js | 57 +++++++++++++++++-------------------- dbus/org.github.PaperWM.xml | 23 ++------------- 2 files changed, 28 insertions(+), 52 deletions(-) diff --git a/dbus.js b/dbus.js index b94f3444a..a87aad982 100644 --- a/dbus.js +++ b/dbus.js @@ -69,7 +69,6 @@ export function disable() { function onBusAcquired(connection, name) { console.log(`${name}: connection acquired`); dbusConnection = connection; - console.log(connection); serviceInstance = new PaperWMService(); exportDBusObject("org.github.PaperWM", serviceInstance, DBUS_PATH); @@ -106,6 +105,9 @@ function onNameAcquired(connection, name) { // console.log(`${name}: name acquired`); } +// find window by id +// global.get_window_actors().find(w => w.get_meta_window().get_id() == the_id) + class PaperWMService { // NOTE: this._impl is set to the exported DBus service before any of the @@ -122,18 +124,21 @@ class PaperWMService { Tiling.spaces, "window-first-frame", (_spaces, metaWindow) => { const space = Tiling.spaces.spaceOfWindow(metaWindow); - this._impl.emit_signal('WindowAdded', - new GLib.Variant('(ssiiibbbb)', [ - metaWindow.wm_class ?? "", - metaWindow.title ?? "", - space.index ?? -1, - space.indexOf(metaWindow) ?? -1, - space.rowOf(metaWindow) ?? -1, - Tiling.isFloating(metaWindow), - Tiling.isScratch(metaWindow), - Tiling.isTransient(metaWindow), - Tiling.isTiled(metaWindow), - ])); + const data = { + wm_class: metaWindow.wm_class, + title: metaWindow.title, + + workspace_index: space.index, + index: space.indexOf(metaWindow), + row: space.rowOf(metaWindow), + floating: Tiling.isFloating(metaWindow), + scratch: Tiling.isScratch(metaWindow), + transient: Tiling.isTransient(metaWindow), + tiled: Tiling.isTiled(metaWindow), + }; + this._impl.emit_signal( + 'WindowAdded', + new GLib.Variant('(s)', [JSON.stringify(data)])); } ); } @@ -143,24 +148,20 @@ class PaperWMService { } // Properties - get ReadOnlyProperty() { - return GLib.Variant.new_string('a string'); - } - - get ReadWriteProperty() { - if (this._readWriteProperty === undefined) + get DebugTrace() { + if (this._debugTrace === undefined) return false; - return this._readWriteProperty; + return this._debugTrace; } - set ReadWriteProperty(value) { - if (this._readWriteProperty === value) + set DebugTrace(value) { + if (this._debugTrace === value) return; - this._readWriteProperty = value; - this._impl.emit_property_changed('ReadWriteProperty', - GLib.Variant.new_boolean(this.ReadWriteProperty)); + this._debugTrace = value; + this._impl.emit_property_changed('DebugTrace', + GLib.Variant.new_boolean(this.DebugTrace)); } // Spaces @@ -236,12 +237,6 @@ class PaperWMService { undoF(); this.undos[undoId] = null; } - - // Signals - emitTestSignal(value) { - this._impl.emit_signal('TestSignal', - new GLib.Variant('(sb)', [value, true])); - } } diff --git a/dbus/org.github.PaperWM.xml b/dbus/org.github.PaperWM.xml index e067460bd..e1cbef807 100644 --- a/dbus/org.github.PaperWM.xml +++ b/dbus/org.github.PaperWM.xml @@ -37,29 +37,10 @@ - - - - - - - - - - - - - - - - - - - + - - + From 0446105603971887a107a241ef7418bb579aca2f Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 3 Feb 2024 14:54:11 +0100 Subject: [PATCH 09/10] Add usage to script --- dbus-send.sh | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/dbus-send.sh b/dbus-send.sh index d9ba87ce7..fdc4c635a 100755 --- a/dbus-send.sh +++ b/dbus-send.sh @@ -1,11 +1,30 @@ #!/usr/bin/env bash -# -# Usage: -# set -euo pipefail +script_name=$(basename "${BASH_SOURCE[0]}") + +usage() { + cat <&2 + usage + exit 1 + fi + while [[ $# -gt 0 ]]; do case "$1" in action) @@ -18,6 +37,15 @@ main() { list_actions return ;; + -h|--help) + usage + exit + ;; + *) + echo "ERROR: Unknown command: $1" >&2 + usage + exit 1 + ;; esac done } From 1dc3489e88ec225ba437ad8cbf9197e2b2fe01f0 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Sat, 3 Feb 2024 15:03:19 +0100 Subject: [PATCH 10/10] Rename script and add usage --- monitor.sh => dbus-monitor.sh | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) rename monitor.sh => dbus-monitor.sh (51%) diff --git a/monitor.sh b/dbus-monitor.sh similarity index 51% rename from monitor.sh rename to dbus-monitor.sh index d0a33b152..d816b93aa 100755 --- a/monitor.sh +++ b/dbus-monitor.sh @@ -1,17 +1,36 @@ #!/usr/bin/env bash # # Usage: -# monitor.sh -# monitor.sh --profile # table like tab separated output -# monitor.sh --signals # only show signals -# monitor.sh FILTER # see https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules -# monitor.sh type=signal +# dbus-monitor.sh +# dbus-monitor.sh --profile # table like tab separated output +# dbus-monitor.sh --signals # only show signals +# dbus-monitor.sh FILTER # see https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules +# dbus-monitor.sh type=signal set -euo pipefail ADDITIONAL_ARGS=() FILTER=("path=/org/github/PaperWM") +script_name=$(basename "${BASH_SOURCE[0]}") + +usage() { + cat <