Skip to content

Commit

Permalink
Add new pane to settings which gives PaperWM debug info (for pasting …
Browse files Browse the repository at this point in the history
…into new issues) (#826)

Fixes #745 

Gathers information from dbus and `metadata.json`:


![image](https://github.com/paperwm/PaperWM/assets/30424662/097023ff-4a87-4aea-a78e-bb0eea61a77e)
  • Loading branch information
jtaala authored Apr 15, 2024
2 parents 033196b + f367a65 commit 4d19389
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 59 deletions.
13 changes: 8 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**System information:**
Please execute `./gather-system-info.sh` in you PaperWM clone and paste the output below.
Please provide system information:
- if you installed PaperWM via [extensions.gnome.org](https://extensions.gnome.org) please open PaperWM settings and select the `About` tab (last tab) and click the `Copy to Clipboard` button and paste the information below, or;

- if you installed via source code, please execute `./gather-system-info.sh` in you PaperWM clone and paste the information below

```
Example:
Distribution: Arch Linux
GNOME Shell 43.3
PaperWM branch/tag: develop
PaperWM commit: 223ff883bca9bf20dbf066eceda891cb6e8be931
Distribution: Fedora Linux 40 (Workstation Edition)
GNOME Shell: 46.0
Display server: Wayland
PaperWM version: 46.4.1
Enabled extensions:
- [email protected]
- [email protected]
Expand Down
94 changes: 48 additions & 46 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1827,58 +1827,60 @@
</object>
</child>
</object>
<object class="GtkPopover" id="about_popover">
<object class="AdwPreferencesPage" id="about_page">
<property name="title" translatable="yes">About</property>
<property name="icon-name">help-about-symbolic</property>
<child>
<object class="GtkBox" id="about">
<property name="focusable">False</property>
<property name="orientation">vertical</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="extension_logo">
<property name="focusable">False</property>
<property name="file">resources/logo.png</property>
</object>
</child>
<child>
<object class="GtkLabel" id="extension_name">
<property name="focusable">False</property>
<property name="label" translatable="yes">&lt;b&gt;PaperWM&lt;/b&gt;</property>
<property name="use_markup">1</property>
<property name="justify">center</property>
</object>
</child>
<child>
<object class="GtkLabel" id="extension_version">
<property name="focusable">False</property>
<property name="label" translatable="yes">$VERSION</property>
<property name="use_markup">1</property>
<property name="justify">center</property>
</object>
</child>
<object class="GtkScrolledWindow" id="about_scrolledWindow">
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkLabel" id="extension_description">
<object class="GtkViewport">
<property name="focusable">False</property>
<property name="label" translatable="yes">Tiled scrollable window manager extension for Gnome Shell</property>
<property name="justify">center</property>
<property name="wrap">1</property>
</object>
</child>
<child>
<object class="GtkLinkButton" id="homepage_link">
<property name="label" translatable="yes">Webpage</property>
<property name="receives_default">1</property>
<property name="uri">https://github.com/paperwm/PaperWM</property>
<property name="vexpand">True</property>
<child>
<object class="GtkBox">
<property name="halign">center</property>
<property name="margin_start">36</property>
<property name="margin_end">36</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="width_request">480</property>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">PaperWM Version Information</property>
<attributes>
<attribute name="weight" value="bold" />
</attributes>
</object>
</child>
<child>
<object class="GtkTextView" id="about_version_textView">
<property name="editable">False</property>
<property name="vexpand">True</property>
<property name="top-margin">6</property>
<property name="right-margin">6</property>
<property name="bottom-margin">6</property>
<property name="left-margin">6</property>
</object>
</child>
<child>
<object class="GtkButton" id="about_version_copy_button">
<property name="label">Copy to Clipboard</property>
<property name="tooltip_text" translatable="yes">Copies PaperWM version information to clipboard</property>
<style>
<class name="suggested-action" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<object class="GtkMenuButton" id="about_button">
<property name="popover">about_popover</property>
<property name="icon-name">dialog-information-symbolic</property>
</object>
</interface>
7 changes: 7 additions & 0 deletions patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ let pillSwipeTimer;
export function enable(extension) {
savedProps = new Map();
gsettings = extension.getSettings();

// save the last display server used
gsettings.set_string(
'last-used-display-server',
Meta.is_wayland_compositor() ? "Wayland" : "Xorg"
);

mutterSettings = new Gio.Settings({ schema_id: 'org.gnome.mutter' });
signals = new Utils.Signals();
setupSwipeTrackers();
Expand Down
120 changes: 112 additions & 8 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Gtk from 'gi://Gtk';

import {
ExtensionPreferences
} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';

import * as Settings from './settings.js';
import { WorkspaceSettings } from './workspace.js';
Expand Down Expand Up @@ -66,12 +64,12 @@ class SettingsWidget {
this.builder.get_object('keybindings_page'),
this.builder.get_object('winprops_page'),
this.builder.get_object('advanced_page'),
this.builder.get_object('about_page'),
];

pages.forEach(page => prefsWindow.add(page));
prefsWindow.set_visible_page(pages[selectedPage]);

this.aboutButton = this.builder.get_object('about_button');
this._backgroundFilter = new Gtk.FileFilter();
this._backgroundFilter.add_pixbuf_formats();

Expand Down Expand Up @@ -378,7 +376,7 @@ class SettingsWidget {
let winprops = this._settings.get_value('winprops').deep_unpack()
.map(p => JSON.parse(p));
// sort a little nicer
let valueFn = wp => {
let valueFn = wp => {
if (wp.wm_class) {
return wp.wm_class;
}
Expand Down Expand Up @@ -443,9 +441,115 @@ class SettingsWidget {
percentValueChanged('maximize-width-percent', 'maximize-width-percent');

// About
let versionLabel = this.builder.get_object('extension_version');
let version = this.extension.metadata.version?.toString() ?? '?';
versionLabel.set_text(version);
// build version information
const text = `
Distribution: ${GLib.get_os_info('NAME') ?? 'UNKNOWN'} ${GLib.get_os_info('VERSION') ?? ""}
GNOME Shell: ${this._getGnomeVersion()}\
${this._getLastDisplayServer()}
PaperWM version: ${this.extension.metadata['version-name'] ?? 'UNKNOWN'}\
${this._getExtensions()}
`.split('\n')
.map(v => v.trim())
.join('\n').trim();

const buffer = new Gtk.TextBuffer();
buffer.set_text(text, -1);

const clipboard = Gdk.Display.get_default()?.get_clipboard();
if (clipboard) {
const copyToClipboard = this.builder.get_object('about_version_copy_button');
copyToClipboard.connect('clicked', () => {
clipboard.set_content(Gdk.ContentProvider.new_for_value(text));
});
}

// set text to buffer
const aboutVersionView = this.builder.get_object('about_version_textView');
aboutVersionView.set_wrap_mode(Gtk.WrapMode.WORD_CHAR);
aboutVersionView.set_buffer(buffer);
}

/**
* Returns the current detected Gnome shell version.
* @returns String
*/
_getGnomeVersion() {
try {
const reply = Gio.DBus.session.call_sync(
'org.gnome.Shell',
'/org/gnome/Shell',
'org.freedesktop.DBus.Properties',
'Get',
new GLib.Variant('(ss)', [
'org.gnome.Shell',
'ShellVersion',
]),
null,
Gio.DBusCallFlags.NONE,
-1,
null);

const [version] = reply.deep_unpack();
return version.deep_unpack();
} catch (error) {
console.error(error);
return 'UNKNOWN';
}
}

/**
* Returns the last used display server (Wayland / X11)
* @returns String
*/
_getLastDisplayServer() {
const ds = this._settings.get_string('last-used-display-server');
if (ds.length > 0) {
return `\nDisplay server: ${ds}`;
}
else {
return "";
}
}

/**
* Returns a formatted list of currently active extensions.
* @returns String
*/
_getExtensions() {
try {
const reply = Gio.DBus.session.call_sync(
'org.gnome.Shell',
'/org/gnome/Shell',
'org.gnome.Shell.Extensions',
'ListExtensions',
null,
new GLib.VariantType('(a{sa{sv}})'),
Gio.DBusCallFlags.NONE,
-1,
null
);

const [ext] = reply.deep_unpack();
const extensions = Object.keys(ext).map(
k => {
return {
uuid: k,
active: ext[k].state.deep_unpack() === 1, // state 1 = active
};
}
)
.filter(v => v.active === true)
.map(v => `- ${v.uuid}`)
.join("\n");

if (extensions.length <= 0) {
return '';
}
return `\nEnabled extensions:\n${extensions}`;
} catch (error) {
console.error(error);
return '\nEnabled extensions: UNKNOWN';
}
}

range(n) {
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
4 changes: 4 additions & 0 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@
</schema>

<schema id="org.gnome.shell.extensions.paperwm" path="/org/gnome/shell/extensions/paperwm/">
<key type="s" name="last-used-display-server">
<default>''</default>
<summary>Saves the last display server used for PaperWM (Wayland / X11)</summary>
</key>

<!-- backup settings (used for restore) -->
<key type="s" name="restore-keybinds">
Expand Down

0 comments on commit 4d19389

Please sign in to comment.