├── .gitignore ├── schemas ├── gschemas.compiled └── org.gnome.shell.extensions.invert-window.gschema.xml ├── metadata.json ├── LICENSE └── extension.js /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | 3 | -------------------------------------------------------------------------------- /schemas/gschemas.compiled: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maiself/gnome-shell-extension-invert-color/HEAD/schemas/gschemas.compiled -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "uuid": "invert-window@maiself", 3 | "name": "Invert Window Color", 4 | "description": "Inverts the color of individual windows\nDefault shortcut is Super+I", 5 | "url": "https://github.com/maiself/gnome-shell-extension-invert-color", 6 | "shell-version": [ 7 | "45", 8 | "46", 9 | "47" 10 | ], 11 | "settings-schema": "org.gnome.shell.extensions.invert-window", 12 | "version": 5 13 | } 14 | -------------------------------------------------------------------------------- /schemas/org.gnome.shell.extensions.invert-window.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | I']]]> 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mai Lavelle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | import * as Main from 'resource:///org/gnome/shell/ui/main.js'; 2 | import Meta from 'gi://Meta'; 3 | import Shell from 'gi://Shell'; 4 | import Clutter from 'gi://Clutter'; 5 | import GObject from 'gi://GObject'; 6 | 7 | import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; 8 | 9 | 10 | const SHORTCUT = 'invert-window-shortcut'; 11 | 12 | export const InvertWindowEffect = GObject.registerClass( 13 | class InvertWindowEffect extends Clutter.ShaderEffect { 14 | vfunc_get_static_shader_source() { 15 | return ' \ 16 | uniform sampler2D tex; \ 17 | void main() { \ 18 | vec4 color = texture2D(tex, cogl_tex_coord_in[0].st); \ 19 | if(color.a > 0.0) { \ 20 | color.rgb /= color.a; \ 21 | } \ 22 | color.rgb = vec3(1.0, 1.0, 1.0) - color.rgb; \ 23 | color.rgb *= color.a; \ 24 | cogl_color_out = color * cogl_color_in; \ 25 | } \ 26 | '; 27 | } 28 | 29 | vfunc_paint_target(...args) { 30 | this.set_uniform_value("tex", 0); 31 | super.vfunc_paint_target(...args); 32 | } 33 | }); 34 | 35 | 36 | export default class InvertWindow extends Extension { 37 | toggle_effect() { 38 | global.get_window_actors().forEach(function(actor) { 39 | let meta_window = actor.get_meta_window(); 40 | if(meta_window.has_focus()) { 41 | if(actor.get_effect('invert-color')) { 42 | actor.remove_effect_by_name('invert-color'); 43 | delete meta_window._invert_window_tag; 44 | } 45 | else { 46 | let effect = new InvertWindowEffect(); 47 | actor.add_effect_with_name('invert-color', effect); 48 | meta_window._invert_window_tag = true; 49 | } 50 | } 51 | }, this); 52 | } 53 | 54 | enable() { 55 | this._settings = this.getSettings(); 56 | 57 | Main.wm.addKeybinding( 58 | SHORTCUT, 59 | this._settings, 60 | Meta.KeyBindingFlags.NONE, 61 | Shell.ActionMode.NORMAL, 62 | () => { this.toggle_effect(); } 63 | ); 64 | 65 | global.get_window_actors().forEach(function(actor) { 66 | let meta_window = actor.get_meta_window(); 67 | if(meta_window.hasOwnProperty('_invert_window_tag')) { 68 | let effect = new InvertWindowEffect(); 69 | actor.add_effect_with_name('invert-color', effect); 70 | } 71 | }, this); 72 | } 73 | 74 | disable() { 75 | Main.wm.removeKeybinding(SHORTCUT); 76 | 77 | global.get_window_actors().forEach(function(actor) { 78 | actor.remove_effect_by_name('invert-color'); 79 | }, this); 80 | 81 | this._settings = null; 82 | } 83 | }; 84 | 85 | 86 | --------------------------------------------------------------------------------