diff options
Diffstat (limited to 'dot_local/share/gnome-shell/extensions/external-display@dotfiles/extension.js')
| -rw-r--r-- | dot_local/share/gnome-shell/extensions/external-display@dotfiles/extension.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dot_local/share/gnome-shell/extensions/external-display@dotfiles/extension.js b/dot_local/share/gnome-shell/extensions/external-display@dotfiles/extension.js new file mode 100644 index 0000000..ce32fd9 --- /dev/null +++ b/dot_local/share/gnome-shell/extensions/external-display@dotfiles/extension.js @@ -0,0 +1,26 @@ +import Meta from "gi://Meta"; +import { Extension } from "resource:///org/gnome/shell/extensions/extension.js"; + +export default class ExternalDisplay extends Extension { + enable() { + this._manager = global.backend.get_monitor_manager(); + this._signal = this._manager.connect("monitors-changed", () => + this._apply(), + ); + this._apply(); + } + + _apply() { + if ( + this._manager.has_builtin_panel && + this._manager.can_switch_config() && + this._manager.get_is_builtin_display_on() + ) + this._manager.switch_config(Meta.MonitorSwitchConfigType.EXTERNAL); + } + + disable() { + this._manager.disconnect(this._signal); + this._manager = null; + } +} |
