Guake / Guake/guake

Workspace switching under Compiz

Open
#1,834 0 comments 0 reactions 0 assignees View on GitHub
Type: Feature Request
Dominant language
Python
Stars
4.7k
Forks
604
PR merge metrics
No merged PRs in 30d

Description

Similar to #1690

When running Ubuntu MATE with Compiz enabled, possibly depending on your Compiz settings, Desktops/Workspaces are reduced to 1 gigantic Desktop/Worspace/ViewPort and implements Virtual Desktops by moving the ViewPort. To effectively track "Workspace" switches you actually need to watch for the `viewports-changed` signal.

The `EWMH` library offers just a wee bit of extended information over `Wnck`, specifically:
* `getDesktopViewPort()` which gives you the current X, Y of the ViewPort
* `getWorkArea()` which gives you the actual width/height of the visible desktop area
* `getDesktopGeometry()` which gives you the entire size of the gigantic desktop

Using these values, we can determine how many virtual workspaces there are - and which one we're on.

For example:
```python
#!/usr/bin/env python3

from ewmh import EWMH
import gi
gi.require_version('Wnck', '3.0')
gi.require_version('Notify', '0.7')
from gi.repository import Wnck, Gtk, Notify
import signal, time

class SigWn:
def __init__(self):
signal.signal(signal.SIGINT, signal.SIG_DFL)
Notify.init("Workspace Switch Notifier")
self.screen = Wnck.Screen.get_default()
self.ewmh = EWMH()
self.desktop_width = self.ewmh.getWorkArea()[2]
self.total_width = self.ewmh.getDesktopGeometry()[0]
self.desktops = int(self.total_width / self.desktop_width)

def on_change(self, window):
current_desktop = int(self.ewmh.getDesktopViewPort()[0] / self.desktop_width) + 1
popup = Notify.Notification.new(f'Desktop: {current_desktop} / {self.desktops}')
popup.show()
time.sleep(1)
popup.close()

def main(self):
self.screen.connect("viewports-changed", self.on_change)
Gtk.main()

if __name__ == '__main__':
app = SigWn()
app.main()
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.