import { Extension } from "resource:///org/gnome/shell/extensions/extension.js" import { setMonitorTransform } from "./monitorDBusUtils.js" export default class AutoRotate extends Extension { _listenerId?: number enable() { let lastFullscreened = false this._listenerId = global.display.connect( "in-fullscreen-changed", () => { const monitors = global.display.get_n_monitors() const isFullscreen = [...new Array(monitors)].findIndex((_, index) => global.display.get_monitor_in_fullscreen(index) ) != -1 if (isFullscreen == lastFullscreened) return lastFullscreened = isFullscreen console.debug(`Fullscreen state changed to: ${isFullscreen}`) setTimeout(() => setMonitorTransform(isFullscreen ? 1 : 0), 50) } ) } disable() { if (this._listenerId != null) global.display.disconnect(this._listenerId) } }