51.5-354 updates
This commit is contained in:
@@ -1,119 +0,0 @@
|
||||
# Deskmeter GNOME Task Indicator
|
||||
|
||||
A GNOME Shell extension that displays your current deskmeter task in the top panel, positioned to the left of the panel indicators.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- GNOME Shell (versions 40-47 supported)
|
||||
- Deskmeter web server running on `http://localhost:10000`
|
||||
- The `/api/current_task` endpoint must be accessible
|
||||
|
||||
## Installation
|
||||
|
||||
1. Copy the extension to your GNOME extensions directory:
|
||||
|
||||
```bash
|
||||
cp -r /home/mariano/wdir/dm/gnome-extension/deskmeter-indicator@local ~/.local/share/gnome-shell/extensions/
|
||||
```
|
||||
|
||||
2. Restart GNOME Shell:
|
||||
- On X11: Press `Alt+F2`, type `r`, and press Enter
|
||||
- On Wayland: Log out and log back in
|
||||
|
||||
3. Enable the extension:
|
||||
|
||||
```bash
|
||||
gnome-extensions enable deskmeter-indicator@local
|
||||
```
|
||||
|
||||
Or use GNOME Extensions app (install with `sudo apt install gnome-shell-extension-prefs` if needed).
|
||||
|
||||
## Configuration
|
||||
|
||||
The extension updates automatically when you switch workspaces. It waits 2.2 seconds after a workspace switch to allow dmcore (which polls every 2 seconds) to detect the change and update MongoDB.
|
||||
|
||||
You can adjust the delay in `extension.js`:
|
||||
|
||||
```javascript
|
||||
const DEBOUNCE_DELAY = 2200; // milliseconds
|
||||
```
|
||||
|
||||
The API URL is set to:
|
||||
|
||||
```javascript
|
||||
const DESKMETER_API_URL = 'http://localhost:10000/api/current_task';
|
||||
```
|
||||
|
||||
## Uninstallation
|
||||
|
||||
```bash
|
||||
gnome-extensions disable deskmeter-indicator@local
|
||||
rm -rf ~/.local/share/gnome-shell/extensions/deskmeter-indicator@local
|
||||
```
|
||||
|
||||
Then restart GNOME Shell.
|
||||
|
||||
## Updating the Extension
|
||||
|
||||
After making changes to the extension code:
|
||||
|
||||
```bash
|
||||
# Use the update script
|
||||
cd /home/mariano/wdir/dm/gnome-extension
|
||||
./update.sh
|
||||
|
||||
# Then restart GNOME Shell (X11 only)
|
||||
Alt+F2, type: r, press Enter
|
||||
|
||||
# On Wayland: log out and back in
|
||||
```
|
||||
|
||||
Or manually:
|
||||
```bash
|
||||
cp -r /home/mariano/wdir/dm/gnome-extension/deskmeter-indicator@local \
|
||||
~/.local/share/gnome-shell/extensions/
|
||||
# Then restart GNOME Shell
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Extension not showing
|
||||
|
||||
1. Check if the extension is enabled:
|
||||
```bash
|
||||
gnome-extensions list --enabled
|
||||
```
|
||||
|
||||
2. Check for errors:
|
||||
```bash
|
||||
journalctl -f -o cat /usr/bin/gnome-shell
|
||||
```
|
||||
|
||||
3. Try disabling and re-enabling:
|
||||
```bash
|
||||
gnome-extensions disable deskmeter-indicator@local
|
||||
gnome-extensions enable deskmeter-indicator@local
|
||||
```
|
||||
|
||||
### Shows "offline" or "error"
|
||||
|
||||
- Ensure dmweb Flask server is running on port 10000
|
||||
- Test the API endpoint:
|
||||
```bash
|
||||
curl http://localhost:10000/api/current_task
|
||||
```
|
||||
Should return JSON like: `{"task_id":"12345678","task_path":"work/default"}`
|
||||
|
||||
### Changes not appearing
|
||||
|
||||
- Make sure you copied files after editing
|
||||
- GNOME Shell must be restarted (no way around this)
|
||||
- Check logs for JavaScript errors: `journalctl -b -o cat /usr/bin/gnome-shell | grep deskmeter`
|
||||
|
||||
### Debug with Looking Glass
|
||||
|
||||
Press `Alt+F2`, type `lg`, press Enter. Go to Extensions tab to see if the extension loaded and check for errors.
|
||||
|
||||
### Task path too long
|
||||
|
||||
The extension automatically truncates paths longer than 40 characters, showing only the last two segments with a `.../ ` prefix.
|
||||
BIN
gnome-extension/deskmeter-indicator@local.zip
Normal file
BIN
gnome-extension/deskmeter-indicator@local.zip
Normal file
Binary file not shown.
@@ -7,8 +7,10 @@ import Clutter from 'gi://Clutter';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
|
||||
const DESKMETER_API_URL = 'http://localhost:10000/api/current_task';
|
||||
// Try common ports - worktree (10001) first, then default (10000)
|
||||
const DEFAULT_PORTS = [10001, 10000];
|
||||
const DEBOUNCE_DELAY = 2200; // Wait 2.2s after workspace switch (dmcore polls every 2s)
|
||||
let DESKMETER_API_URL = null;
|
||||
|
||||
const TaskIndicator = GObject.registerClass(
|
||||
class TaskIndicator extends PanelMenu.Button {
|
||||
@@ -17,7 +19,7 @@ class TaskIndicator extends PanelMenu.Button {
|
||||
|
||||
// Create label for task display
|
||||
this._label = new St.Label({
|
||||
text: 'loading...',
|
||||
text: 'detecting...',
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
style_class: 'deskmeter-task-label'
|
||||
});
|
||||
@@ -26,6 +28,7 @@ class TaskIndicator extends PanelMenu.Button {
|
||||
|
||||
this._debounceTimeout = null;
|
||||
this._workspaceManager = global.workspace_manager;
|
||||
this._apiUrl = null;
|
||||
|
||||
// Connect to workspace switch signal
|
||||
this._workspaceSwitchedId = this._workspaceManager.connect(
|
||||
@@ -33,8 +36,46 @@ class TaskIndicator extends PanelMenu.Button {
|
||||
this._onWorkspaceSwitched.bind(this)
|
||||
);
|
||||
|
||||
// Initial update
|
||||
this._scheduleUpdate();
|
||||
// Detect API port, then start updates
|
||||
this._detectApiPort();
|
||||
}
|
||||
|
||||
_detectApiPort() {
|
||||
// Try each port in sequence
|
||||
this._tryNextPort(0);
|
||||
}
|
||||
|
||||
_tryNextPort(index) {
|
||||
if (index >= DEFAULT_PORTS.length) {
|
||||
// No ports responded, use default and let it show "offline"
|
||||
this._apiUrl = `http://localhost:${DEFAULT_PORTS[DEFAULT_PORTS.length - 1]}/api/current_task`;
|
||||
this._scheduleUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
const port = DEFAULT_PORTS[index];
|
||||
const url = `http://localhost:${port}/api/current_task`;
|
||||
|
||||
try {
|
||||
let file = Gio.File.new_for_uri(url);
|
||||
file.load_contents_async(null, (source, result) => {
|
||||
try {
|
||||
let [success, contents] = source.load_contents_finish(result);
|
||||
if (success) {
|
||||
// Port responded, use it
|
||||
this._apiUrl = url;
|
||||
this._scheduleUpdate();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// This port failed, try next
|
||||
this._tryNextPort(index + 1);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// This port failed, try next
|
||||
this._tryNextPort(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
_onWorkspaceSwitched() {
|
||||
@@ -58,9 +99,14 @@ class TaskIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_updateTask() {
|
||||
if (!this._apiUrl) {
|
||||
this._label.set_text('detecting...');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Create HTTP request
|
||||
let file = Gio.File.new_for_uri(DESKMETER_API_URL);
|
||||
let file = Gio.File.new_for_uri(this._apiUrl);
|
||||
file.load_contents_async(null, (source, result) => {
|
||||
try {
|
||||
let [success, contents] = source.load_contents_finish(result);
|
||||
@@ -95,17 +141,22 @@ class TaskIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this._debounceTimeout) {
|
||||
GLib.source_remove(this._debounceTimeout);
|
||||
this._debounceTimeout = null;
|
||||
}
|
||||
try {
|
||||
if (this._debounceTimeout) {
|
||||
GLib.source_remove(this._debounceTimeout);
|
||||
this._debounceTimeout = null;
|
||||
}
|
||||
|
||||
if (this._workspaceSwitchedId) {
|
||||
this._workspaceManager.disconnect(this._workspaceSwitchedId);
|
||||
this._workspaceSwitchedId = null;
|
||||
}
|
||||
if (this._workspaceSwitchedId) {
|
||||
this._workspaceManager.disconnect(this._workspaceSwitchedId);
|
||||
this._workspaceSwitchedId = null;
|
||||
}
|
||||
|
||||
super.destroy();
|
||||
super.destroy();
|
||||
} catch (e) {
|
||||
// Log error but don't crash GNOME Shell
|
||||
logError(e, 'Failed to destroy TaskIndicator');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -115,17 +166,38 @@ export default class Extension {
|
||||
}
|
||||
|
||||
enable() {
|
||||
this._indicator = new TaskIndicator();
|
||||
try {
|
||||
this._indicator = new TaskIndicator();
|
||||
|
||||
// Add to panel - position after workspace indicator
|
||||
// Panel boxes: left, center, right
|
||||
// We'll add it to the left panel, after other items
|
||||
Main.panel.addToStatusArea('deskmeter-task-indicator', this._indicator, 1, 'left');
|
||||
// Add to panel - position after workspace indicator
|
||||
// Panel boxes: left, center, right
|
||||
// We'll add it to the left panel, after other items
|
||||
Main.panel.addToStatusArea('deskmeter-task-indicator', this._indicator, 1, 'left');
|
||||
} catch (e) {
|
||||
// Log error but don't crash GNOME Shell
|
||||
logError(e, 'Failed to enable Deskmeter extension');
|
||||
|
||||
// Clean up if partially initialized
|
||||
if (this._indicator) {
|
||||
try {
|
||||
this._indicator.destroy();
|
||||
} catch (destroyError) {
|
||||
logError(destroyError, 'Failed to cleanup indicator');
|
||||
}
|
||||
this._indicator = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disable() {
|
||||
if (this._indicator) {
|
||||
this._indicator.destroy();
|
||||
try {
|
||||
if (this._indicator) {
|
||||
this._indicator.destroy();
|
||||
this._indicator = null;
|
||||
}
|
||||
} catch (e) {
|
||||
// Log error but don't crash GNOME Shell
|
||||
logError(e, 'Failed to disable Deskmeter extension');
|
||||
this._indicator = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
"44",
|
||||
"45",
|
||||
"46",
|
||||
"47"
|
||||
"47",
|
||||
"48",
|
||||
"49"
|
||||
],
|
||||
"url": "",
|
||||
"version": 1
|
||||
|
||||
Reference in New Issue
Block a user