├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── images ├── after.png └── before.png ├── lib └── gtk-dark-theme.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * First initial version 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Stephen Coakley 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GTK Dark Theme Variant for Atom 2 | A simple plugin for [Atom](http://atom.io) that enables you to toggle the [dark theme variant](https://developer.gnome.org/gtk3/3.0/GtkSettings.html#GtkSettings--gtk-application-prefer-dark-theme) in Atom on GTK+ 3-based desktop environments that support it. GNOME 3 is the most common shell that supports this. 3 | 4 | You can use this to enable the dark variant of your current desktop theme for Atom windows, which results in a much more beautiful interface when using dark UI themes. Note that this currently does not affect the menu bar. 5 | 6 | This package is inspired by and is based off of the [GTKDarkThemeVariantSetter](https://github.com/p-e-w/GTKDarkThemeVariantSetter) plugin for Sublime Text. Credit should be given to [Philipp Weidmann](http://github.com/p-e-w) for the steps to modify an open window's theme. 7 | 8 | ### Before (GNOME 3): 9 | ![Before](https://raw.githubusercontent.com/coderstephen/atom-gtk-dark-theme/master/images/before.png) 10 | 11 | ### After: 12 | ![After](https://raw.githubusercontent.com/coderstephen/atom-gtk-dark-theme/master/images/after.png) 13 | 14 | ## Installation 15 | Via `apm`: 16 | 17 | apm install gtk-dark-theme 18 | 19 | ## Usage 20 | To enable the dark theme, open the command palette (Shift+Ctrl+P) and select "Gtk Dark Theme: Enable" from the list. To disable the dark theme, open the command palette and select "Gtk Dark Theme: Disable" from the list. 21 | 22 | Your current choice will be remembered the next time you open Atom. 23 | 24 | ## License 25 | This package is licensed under the MIT License. See [the license file](LICENSE.md) for details. 26 | -------------------------------------------------------------------------------- /images/after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagebind/atom-gtk-dark-theme/85eebb41067d95d0c9cbee71c8323db3ca842d71/images/after.png -------------------------------------------------------------------------------- /images/before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagebind/atom-gtk-dark-theme/85eebb41067d95d0c9cbee71c8323db3ca842d71/images/before.png -------------------------------------------------------------------------------- /lib/gtk-dark-theme.js: -------------------------------------------------------------------------------- 1 | var exec = require('child_process').exec; 2 | 3 | module.exports = { 4 | config: { 5 | enabled: { 6 | type: 'boolean', 7 | default: true 8 | } 9 | }, 10 | 11 | /** 12 | * Activates the package. 13 | */ 14 | activate: function() { 15 | atom.commands.add('atom-workspace', 'gtk-dark-theme:enable', this.enable); 16 | atom.commands.add('atom-workspace', 'gtk-dark-theme:disable', this.disable); 17 | 18 | // Automatically enable dark theme if it was enabled last time we ran. 19 | if (atom.config.get('gtk-dark-theme.enabled')) { 20 | this.enable(); 21 | } 22 | }, 23 | 24 | /** 25 | * Enables the GTK dark theme. 26 | */ 27 | enable: function() { 28 | console.log('Setting GTK theme variant to "dark".'); 29 | setAtomGtkTheme('dark').then(function () { 30 | atom.config.set('gtk-dark-theme.enabled', true); 31 | }); 32 | }, 33 | 34 | /** 35 | * Disables the GTK dark theme. 36 | */ 37 | disable: function() { 38 | console.log('Setting GTK theme variant to "light".'); 39 | setAtomGtkTheme('light').then(function () { 40 | atom.config.set('gtk-dark-theme.enabled', false); 41 | }); 42 | } 43 | }; 44 | 45 | 46 | /** 47 | * Gets the handle IDs of all currently open Atom windows. 48 | * 49 | * @return Promise 50 | */ 51 | function getAtomWindowHandles() { 52 | return new Promise(function(resolve, reject) { 53 | //var windows = [atom.getCurrentWindow()]; 54 | var windows = require('electron').remote.BrowserWindow.getAllWindows(); 55 | 56 | var ids = windows.map(w => w.getNativeWindowHandle().readUInt32LE()); 57 | 58 | resolve(ids); 59 | }); 60 | } 61 | 62 | /** 63 | * Sets the GTK theme variant of all Atom windows. 64 | * 65 | * @param [String] variant The GTK theme variant to set. 66 | * 67 | * @return Promise 68 | */ 69 | function setAtomGtkTheme(theme) { 70 | return getAtomWindowHandles().then(function(handles) { 71 | var promises = []; 72 | 73 | for (var i = 0; i < handles.length; i++) { 74 | var cmd = 'xprop -id ' 75 | + handles[i] 76 | + ' -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT ' 77 | + theme; 78 | 79 | promises.push(new Promise(function(resolve, reject) { 80 | exec(cmd, function(error, stdout, stderr) { 81 | if (error) { 82 | reject(error); 83 | } else { 84 | resolve(); 85 | } 86 | }); 87 | })); 88 | } 89 | 90 | return Promise.all(promises); 91 | }); 92 | } 93 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gtk-dark-theme", 3 | "main": "./lib/gtk-dark-theme", 4 | "version": "0.1.4", 5 | "description": "Toggles the dark theme variant for Atom windows on GTK+ 3", 6 | "keywords": [ 7 | "gtk", 8 | "dark theme" 9 | ], 10 | "repository": "https://github.com/coderstephen/atom-gtk-dark-theme", 11 | "license": "MIT", 12 | "engines": { 13 | "atom": ">=1.0.0 <2.0.0" 14 | } 15 | } 16 | --------------------------------------------------------------------------------