├── README ├── .no-sublime-package ├── transparency ├── __init__.py └── commands │ ├── __init__.py │ └── settings.py ├── SublimeTextTrans.message ├── snapshot.png ├── lib ├── SetSublimeLayered.exe └── SetSublimeLayered.asm ├── Default (Linux).sublime-keymap ├── Default (Windows).sublime-keymap ├── Context.sublime-menu ├── LICENSE ├── .gitattributes ├── SublimeTextTrans.sublime-settings ├── messages └── install.txt ├── .gitignore ├── Main.sublime-menu ├── Readme.md └── SublimeTrans.py /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.no-sublime-package: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /transparency/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SublimeTextTrans.message: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt" 3 | } 4 | -------------------------------------------------------------------------------- /snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vhanla/SublimeTextTrans/HEAD/snapshot.png -------------------------------------------------------------------------------- /lib/SetSublimeLayered.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vhanla/SublimeTextTrans/HEAD/lib/SetSublimeLayered.exe -------------------------------------------------------------------------------- /transparency/commands/__init__.py: -------------------------------------------------------------------------------- 1 | from .settings import ( 2 | TransparencyOpenPluginDefaultSettingsFile, 3 | TransparencyOpenHelpFile 4 | ) 5 | 6 | __all__ = [ 7 | "TransparencyOpenPluginDefaultSettingsFile", 8 | "TransparencyOpenHelpFile" 9 | ] -------------------------------------------------------------------------------- /Default (Linux).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | { "keys": ["ctrl+shift+1"], "command": "set_opacity"}, 3 | { "keys": ["ctrl+shift+2"], "command": "set_opacity_nine" }, 4 | { "keys": ["ctrl+shift+3"], "command": "set_opacity_eight" }, 5 | { "keys": ["ctrl+shift+4"], "command": "set_opacity_seven" }, 6 | { "keys": ["ctrl+shift+5"], "command": "set_opacity_six" }, 7 | { "keys": ["ctrl+shift+6"], "command": "set_opacity_half" } 8 | ] 9 | -------------------------------------------------------------------------------- /Default (Windows).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | { "keys": ["ctrl+shift+1"], "command": "set_opacity"}, 3 | { "keys": ["ctrl+shift+2"], "command": "set_opacity_nine" }, 4 | { "keys": ["ctrl+shift+3"], "command": "set_opacity_eight" }, 5 | { "keys": ["ctrl+shift+4"], "command": "set_opacity_seven" }, 6 | { "keys": ["ctrl+shift+5"], "command": "set_opacity_six" }, 7 | { "keys": ["ctrl+shift+6"], "command": "set_opacity_half" } 8 | ] 9 | -------------------------------------------------------------------------------- /Context.sublime-menu: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": "sublimetransmenu", 3 | "caption": "Window's Transparency", 4 | "children": [{ 5 | "id": "sublimetranssubmenu1", 6 | "caption": "About", 7 | "checkbox": true, 8 | "command": "sub_trans_about" 9 | }, 10 | { "caption": "-" }, 11 | { "id": "sublimetranssubmenunine", "caption": "Level 5", "command": "set_opacity_half", "checkbox": true }, 12 | { "id": "sublimetranssubmenueight", "caption": "Level 4", "command": "set_opacity_six", "checkbox": true }, 13 | { "id": "sublimetranssubmenuseven", "caption": "Level 3", "command": "set_opacity_seven", "checkbox": true }, 14 | { "id": "sublimetranssubmenusix", "caption": "Level 2", "command": "set_opacity_eight", "checkbox": true }, 15 | { "id": "sublimetranssubmenuhalf", "caption": "Level 1", "command": "set_opacity_nine", "checkbox": true }, 16 | { "caption": "-" }, 17 | { 18 | "id": "sublimetranssubmenu3", 19 | "caption": "Disable", 20 | "command": "set_opacity", 21 | "checkbox": true 22 | }] 23 | }] 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013 vhanla 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. -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.doc diff=astextplain 2 | *.DOC diff=astextplain 3 | *.docx diff=astextplain 4 | *.DOCX diff=astextplain 5 | *.dot diff=astextplain 6 | *.DOT diff=astextplain 7 | *.pdf diff=astextplain 8 | *.PDF diff=astextplain 9 | *.rtf diff=astextplain 10 | *.RTF diff=astextplain 11 | 12 | *.jpg binary 13 | *.png binary 14 | *.gif binary 15 | 16 | *.cs text=auto diff=csharp 17 | *.vb text=auto 18 | *.c text=auto 19 | *.cpp text=auto 20 | *.cxx text=auto 21 | *.h text=auto 22 | *.hxx text=auto 23 | *.py text=auto 24 | *.rb text=auto 25 | *.java text=auto 26 | *.html text=auto 27 | *.htm text=auto 28 | *.css text=auto 29 | *.scss text=auto 30 | *.sass text=auto 31 | *.less text=auto 32 | *.js text=auto 33 | *.lisp text=auto 34 | *.clj text=auto 35 | *.sql text=auto 36 | *.php text=auto 37 | *.lua text=auto 38 | *.m text=auto 39 | *.asm text=auto 40 | *.erl text=auto 41 | *.fs text=auto 42 | *.fsx text=auto 43 | *.hs text=auto 44 | 45 | *.csproj text=auto merge=union 46 | *.vbproj text=auto merge=union 47 | *.fsproj text=auto merge=union 48 | *.dbproj text=auto merge=union 49 | *.sln text=auto eol=crlf merge=union 50 | -------------------------------------------------------------------------------- /transparency/commands/settings.py: -------------------------------------------------------------------------------- 1 | import sublime_plugin 2 | import sublime 3 | 4 | import os 5 | from os.path import dirname 6 | 7 | ST2 = int(sublime.version()) < 3000 8 | 9 | if not ST2: 10 | PLUGIN_DIR = dirname(dirname(dirname(os.path.abspath(__file__)))) 11 | else: 12 | _st_pkgs_dir = sublime.packages_path() 13 | _cur_file_abspath = os.path.abspath(__file__) 14 | if _st_pkgs_dir not in _cur_file_abspath: 15 | for p in os.listdir(_st_pkgs_dir): 16 | link_path = _st_pkgs_dir + os.sep + p 17 | if os.path.realpath(link_path) in _cur_file_abspath: 18 | PLUGIN_DIR = link_path 19 | break 20 | else: 21 | PLUGIN_DIR = dirname(dirname(dirname(os.path.abspath(__file__)))) 22 | 23 | class TransparencyOpenPluginDefaultSettingsFile(sublime_plugin.WindowCommand): 24 | def run(self): 25 | default_plugin_settings_path = os.path.join(PLUGIN_DIR, "SublimeTextTrans.sublime-settings") 26 | sublime.active_window().open_file(default_plugin_settings_path) 27 | 28 | class TransparencyOpenHelpFile(sublime_plugin.WindowCommand): 29 | def run(self): 30 | help_file_path = os.path.join(PLUGIN_DIR, "messages/install.txt") 31 | sublime.active_window().open_file(help_file_path) -------------------------------------------------------------------------------- /SublimeTextTrans.sublime-settings: -------------------------------------------------------------------------------- 1 | // SublimeTextTrans default settings 2 | // 3 | // In order to tweak the settings, you should NOT edit this file, but instead 4 | // the user-specific, empty-by-default version under: 5 | // "Preferences / Package Settings / SublimeTextTrans / Settings - User". 6 | // 7 | // See SublimeTextTrans' README for more information. 8 | { 9 | 10 | // Auto apply on file open 11 | "autoapply": true, 12 | 13 | // Don't modify this value, it will be updated automatically 14 | // it's meant to be used as the level to remember on startup 15 | "opacity": 228, 16 | 17 | // It will set the default levels of opacity 18 | 19 | // If you like to have a different transparency level 20 | // modify this array of options in your user preferences 21 | // i.e. just add (copy/paste) this array and modify at wish 22 | // IMPORTANT: Level of opacity varies from 0 to 255 23 | // 0 = Totally transparent, 255 = Fully opaque 24 | // ORDER is important, it has its correspondent menu item/hotkey 25 | "levels": [ 26 | 255, // Full opaque i.e not transparent - a.k.a Disabled, recommended to leave it as 255 [Ctrl+Shift+1] 27 | 212, // Level 5 - [Ctrl+Shift+6] 28 | 220, // Level 4 - [Ctrl+Shift+5] 29 | 228, // Level 3 - [Ctrl+Shift+4] 30 | 236, // Level 2 - [Ctrl+Shift+3] 31 | 243 // Level 1 - [Ctrl+Shift+2] 32 | ] 33 | } -------------------------------------------------------------------------------- /lib/SetSublimeLayered.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; SetSublimeLayered.asm 3 | ; created by vhanla 4 | ; 5 | ; this console based utiliy will set sublimetext to layered mode 6 | ; required to adjust alpha opacity 7 | ; 8 | ; compiled with FlatAssembler 1.70 9 | ; http://flatassembler.net 10 | ; 11 | ; Changelog: 12 | ; 2018-04-14 13 | ; - Replaced custom atoi function by msvcrt.dll atoi import 14 | ; - Rearranged PE sections to avoid most false positives on VirusTotal 15 | ; currently (at this date) only one detects as Unsafe 16 | 17 | format PE CONSOLE 4.0 18 | include '%include%\win32a.inc' 19 | 20 | entry start 21 | 22 | start: 23 | cinvoke __getmainargs,argc,argv,env,0 24 | cmp [argc],3 25 | jne error 26 | mov esi,[argv] 27 | 28 | ;this is the HWND (SublimeText3 handle id) 29 | cinvoke strtoint, dword[esi+4] 30 | mov ebx, eax 31 | ;this is the current exstyle 32 | cinvoke strtoint, dword[esi+8] 33 | mov ecx, eax 34 | or ecx, WS_EX_LAYERED 35 | invoke SetWindowLong, ebx, GWL_EXSTYLE, ecx 36 | 37 | finish: 38 | invoke ExitProcess,0 39 | 40 | error: 41 | cinvoke printf,errmsg 42 | jmp finish 43 | 44 | 45 | argc dd ? 46 | argv dd ? 47 | env dd ? 48 | errmsg db "It is required two parameters!",0 49 | 50 | 51 | data import 52 | 53 | library kernel,'KERNEL32.DLL',\ 54 | msvcrt,'msvcrt.dll',\ 55 | user,'USER32.DLL' 56 | 57 | import kernel,\ 58 | ExitProcess,'ExitProcess' 59 | 60 | import user,\ 61 | SetWindowLong,'SetWindowLongA' 62 | 63 | 64 | import msvcrt,\ 65 | __getmainargs,'__getmainargs',\ 66 | printf,'printf',\ 67 | strtoint,'atoi' 68 | end data -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeText Transparent 2 | ======================= 3 | 4 | Overview 5 | -------- 6 | This simple plugin for Sublime Text 2 and Sublime Text 3/4 provides contextual menues to modify the application's opacity. 7 | 8 | Requirements: 9 | - Windows: SetSublimeLayered.exe in lib directory in the package 10 | That's required since changing Sublime Text's windows to layered mode from within the extension itself 11 | hangs the editor, maybe a Python embedded bug. 12 | Notice: The source code of it is in a simple very tiny assembly that compiles with FlatAssembler, but some AV shows as False Positive, 13 | which is weird for a really tiny executable (1024 bytes) 😅 14 | - Linux: It relies on `wmctrl` and `xprop`, the first to get the sublime_text.Sublime_text class instances (Windows), 15 | and the second one, to set the opacity level of the matching Sublime Text's windows. 16 | - macOS: Unsupported. 17 | 18 | Usage: 19 | ------- 20 | There are three methods to set transparency: 21 | 22 | 1. Visit `View > Window's Transparency` submenu to set the opacity 23 | 2. You can use the hotkeys `Ctrl+Shift+[1,2,3,4,5,6]` 24 | 3. Or you can right click and use the contextual menu 25 | 26 | 27 | Configuration: 28 | -------------- 29 | To set custom transparency levels visit `Preferences > Package Settings > SublimeTextTrans > Settings - User`, it will open the user's custom preferences file for this plugin. 30 | 31 | There you can modify the transparency levels, by adding the following and adjusting the levels as you wish: 32 | 33 | { 34 | 35 | // If you like to have a different transparency level 36 | // modify this array of options in your user preferences 37 | // i.e. just add (copy/paste) this array and modify at wish 38 | // IMPORTANT: Level of opacity varies from 0 to 255 39 | // 0 = Totally transparent, 255 = Fully opaque 40 | // ORDER is important, it has its correspondent menu item/hotkey 41 | "levels": [ 42 | 255, // Full opaque i.e not transparent - a.k.a Disabled, recommended to leave it as 255 [Ctrl+Shift+1] 43 | 212, // Level 5 - [Ctrl+Shift+6] 44 | 220, // Level 4 - [Ctrl+Shift+5] 45 | 228, // Level 3 - [Ctrl+Shift+4] 46 | 236, // Level 2 - [Ctrl+Shift+3] 47 | 243 // Level 1 - [Ctrl+Shift+2] 48 | ] 49 | } 50 | 51 | You can enable or disable autoapply transparency on ST load automatically by adding to the user settings: 52 | { 53 | "autoapply": true // false to disable 54 | } 55 | 56 | Or just open default settings, copy it and paste it in your user settings, modifiy as you wish and save your new settings. 57 | 58 | 59 | Report issues at: https://github.com/vhanla/SublimeTextTrans/issues 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ################# 3 | ## Eclipse 4 | ################# 5 | 6 | *.pydevproject 7 | .project 8 | .metadata 9 | bin/** 10 | tmp/** 11 | tmp/**/* 12 | *.tmp 13 | *.bak 14 | *.swp 15 | *~.nib 16 | local.properties 17 | .classpath 18 | .settings/ 19 | .loadpath 20 | 21 | # External tool builders 22 | .externalToolBuilders/ 23 | 24 | # Locally stored "Eclipse launch configurations" 25 | *.launch 26 | 27 | # CDT-specific 28 | .cproject 29 | 30 | # PDT-specific 31 | .buildpath 32 | 33 | 34 | ################# 35 | ## Visual Studio 36 | ################# 37 | 38 | ## Ignore Visual Studio temporary files, build results, and 39 | ## files generated by popular Visual Studio add-ons. 40 | 41 | # User-specific files 42 | *.suo 43 | *.user 44 | *.sln.docstates 45 | 46 | # Build results 47 | **/[Dd]ebug/ 48 | **/[Rr]elease/ 49 | *_i.c 50 | *_p.c 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.vspscc 65 | .builds 66 | **/*.dotCover 67 | 68 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 69 | #**/packages/ 70 | 71 | # Visual C++ cache files 72 | ipch/ 73 | *.aps 74 | *.ncb 75 | *.opensdf 76 | *.sdf 77 | 78 | # Visual Studio profiler 79 | *.psess 80 | *.vsp 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper* 84 | 85 | # Installshield output folder 86 | [Ee]xpress 87 | 88 | # DocProject is a documentation generator add-in 89 | DocProject/buildhelp/ 90 | DocProject/Help/*.HxT 91 | DocProject/Help/*.HxC 92 | DocProject/Help/*.hhc 93 | DocProject/Help/*.hhk 94 | DocProject/Help/*.hhp 95 | DocProject/Help/Html2 96 | DocProject/Help/html 97 | 98 | # Click-Once directory 99 | publish 100 | 101 | # Others 102 | [Bb]in 103 | [Oo]bj 104 | sql 105 | TestResults 106 | *.Cache 107 | ClientBin 108 | stylecop.* 109 | ~$* 110 | *.dbmdl 111 | Generated_Code #added for RIA/Silverlight projects 112 | 113 | # Backup & report files from converting an old project file to a newer 114 | # Visual Studio version. Backup files are not needed, because we have git ;-) 115 | _UpgradeReport_Files/ 116 | Backup*/ 117 | UpgradeLog*.XML 118 | 119 | 120 | 121 | ############ 122 | ## Windows 123 | ############ 124 | 125 | # Windows image file caches 126 | Thumbs.db 127 | 128 | # Folder config file 129 | Desktop.ini 130 | 131 | 132 | ############# 133 | ## Python 134 | ############# 135 | 136 | *.py[co] 137 | 138 | # Packages 139 | *.egg 140 | *.egg-info 141 | dist 142 | build 143 | eggs 144 | parts 145 | bin 146 | var 147 | sdist 148 | develop-eggs 149 | .installed.cfg 150 | 151 | # Installer logs 152 | pip-log.txt 153 | 154 | # Unit test / coverage reports 155 | .coverage 156 | .tox 157 | 158 | #Translations 159 | *.mo 160 | 161 | #Mr Developer 162 | .mr.developer.cfg 163 | 164 | # Mac crap 165 | .DS_Store 166 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "view", 4 | "children": 5 | [ 6 | { 7 | "caption": "Window's Transparency", 8 | "id": "sublimetransview1", 9 | "children": 10 | [{ 11 | "id": "sublimetranssubmenu1", 12 | "caption": "About", 13 | "command": "sub_trans_about" 14 | }, 15 | { "caption": "-" }, 16 | { "id": "sublimetranssubmenunine", "caption": "Level 5", "command": "set_opacity_half", "checkbox": true }, 17 | { "id": "sublimetranssubmenueight", "caption": "Level 4", "command": "set_opacity_six", "checkbox": true }, 18 | { "id": "sublimetranssubmenuseven", "caption": "Level 3", "command": "set_opacity_seven", "checkbox": true }, 19 | { "id": "sublimetranssubmenusix", "caption": "Level 2", "command": "set_opacity_eight", "checkbox": true }, 20 | { "id": "sublimetranssubmenuhalf", "caption": "Level 1", "command": "set_opacity_nine", "checkbox": true }, 21 | { "caption": "-" }, 22 | { 23 | "id": "sublimetranssubmenu3", 24 | "caption": "Disable", 25 | "command": "set_opacity", 26 | "checkbox": true 27 | }] 28 | } 29 | ] 30 | }, 31 | { 32 | "id": "preferences", 33 | "children": 34 | [ 35 | { 36 | "caption": "Package Settings", 37 | "mnemonic": "P", 38 | "id": "package-settings", 39 | "children": 40 | [ 41 | { 42 | "caption": "SublimeTextTrans", 43 | "children": 44 | [ 45 | { 46 | "id": "sublimetranssubmenu1", 47 | "caption": "About", 48 | "checkbox": true, 49 | "command": "sub_trans_about" 50 | }, 51 | { 52 | "command": "transparency_open_help_file", 53 | "caption": "Help" 54 | }, 55 | { "caption": "-"}, 56 | { 57 | "command": "transparency_open_plugin_default_settings_file", 58 | "caption": "Settings - Default" 59 | }, 60 | { 61 | "command": "open_file", 62 | "args": { 63 | "file": "${packages}/User/SublimeTextTrans.sublime-settings", 64 | "platform": "Windows" 65 | }, 66 | "caption": "Settings - User" 67 | } 68 | ] 69 | } 70 | ] 71 | } 72 | 73 | 74 | ] 75 | } 76 | ] -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | SublimeText Transparent 2 | ======================= 3 | `Package Name : Transparency` 4 | 5 | Overview 6 | -------- 7 | This simple plugin for Sublime Text 2 and Sublime Text 3 & 4 provides contextual menues and hotkeys to modify the application's opacity. 8 | 9 | **This is only for SublimeText under Windows and Linux.** 10 | 11 | 12 | Install 13 | ------- 14 | 15 | **Using Package Installer:** 16 | 17 | Ctrl+Shift+P - Install Package - Transparency 18 | 19 | You may also install `SublimeTextTrans` via git with the below commands: 20 | 21 | **Windows and Linux only** 22 | 23 | Requirements: 24 | 25 | - 🪟**Windows**: compiled SetSublimeLayered.asm to exe which is included already using FlatAssembler, only 1024 bytes binary. 26 | 27 | Why is that? 28 | 29 | To change a window's opacity in Windows to a certain alpha opacity level, it needs first to be in LayeredMode which is not by default the Sublime Text's windows. 30 | 31 | And invoking SetWindowLong from Python's embedded by Sublime Text in order to do that change, hangs the Sublime Text's window. SetSublimeLayered is a workaround which receives the Sublime Text's window handle(id) and changes to WS_EX_LAYERED mode. 32 | 33 | **Notice**: Some Anti Malware false positives this really tiny executable, which is weird, so the source code is included in its ./lib directory, if you have issues with that, you can recompile yourself with FlatAssembler, and if your AntiVirusMalware software keeps as False Positive, maybe you should white list it or consider switching to a more reliable AV software. 34 | 35 | 36 | - 🐧**Linux**: `wmctrl` and `xprop` installed in your system, since they will be called to find the Sublime Text's windows and changing their opacity levels. 37 | 38 | **For Sublime Installed:** 39 | 40 | git clone https://github.com/vhanla/SublimeTextTrans.git "%APPDATA%\Sublime Text 2\Packages\Transparency" 41 | 42 | **Notice** that this location might change on each SublimeText version, _you can find the correct path by going to menu **Preferences - Browse Packages**_ 43 | 44 | **For Sublime as Portable:** 45 | 46 | git clone https://github.com/vhanla/SublimeTextTrans.git "C:\Sublime\Data\Packages\Transparency" 47 | 48 | *Where* ***C:\Sublime*** *is the portable's path. So change accordingly.* 49 | 50 | You can also get it zipped from the [Releases](https://github.com/vhanla/SublimeTextTrans/releases) section. 51 | 52 | Remember, this plugin must be inside its own directory within packages directory where you will unzip it. 53 | 54 | 55 | Usage: 56 | ------- 57 | There are three methods to set transparency: 58 | 59 | 1. Visit `View > Window's Transparency` submenu to set the opacity 60 | 2. You can use the hotkeys `Ctrl+Shift+[1,2,3,4,5,6]` 61 | 3. Or you can right click and use the contextual menu 62 | 63 | ![](https://github.com/vhanla/SublimeTextTrans/raw/master/snapshot.png?raw=true) 64 | 65 | Limitations: 66 | ------------ 67 | - Only 6 levels of transparency, [0 = invisible <-> 255 = solid] customizable on settings file. 68 | - It requires another executable to change Sublime Text's window style mode to allow translucency. 69 | However, you don't need to install it or launch manually, the plugin does it for you. Executable is only a `1024 bytes` and source code is included, which is in assembler language, hence that's why it is so small. Also, it is launched only once each time you start Sublime Text, and it closes itself after changing style, so no memory is used afterwards. 70 | 71 | 72 | Changelog: 73 | ---------- 74 | [15-02-2025] v1.5 75 | - Fixed default levels that on rare situations might not be set. 76 | - Support for Linux (X11) with wmctrl and xprop installed. 77 | 78 | [16-05-2018] v1.4 79 | 80 | - Fixed opening default settings and help menu 81 | - Improved window listing on ST3 82 | - Fixed issue #3 thanks to @rexdf 83 | - Only call external executable if ST2/3 window is not already WS_EX_LAYERED 84 | 85 | [14-04-2018] v1.3 86 | 87 | - Modified `SetSublimeLayered.asm` to make it smaller and to avoid false positives (tested on [VirusTotal](https://www.virustotal.com/#/file/66b72c28f54728c6df3995b0ae026aa1aeeca96911d5b484673a502ec6592f2a/detection)) 88 | 89 | These are `SetSublimeLayered.exe`hashes: 90 | 91 | - SHA-256 66b72c28f54728c6df3995b0ae026aa1aeeca96911d5b484673a502ec6592f2a 92 | - CRC32 54612762 93 | - MD5 E113BDC6FA08BC054F7A89E7B24411BD 94 | - SHA-1 376707D5579384B42586D0616BB03BBB993C6050 95 | 96 | [15-04-2015] v1.2 97 | 98 | - Onload transparency (95% working due to ST API limitations) 99 | - Remember chosen transparency level 100 | - Support for user settings 101 | 102 | [12-06-2013] v1.0 103 | 104 | - Added support for Sublime Text 3 105 | 106 | Configuration: 107 | -------------- 108 | To set custom transparency levels visit `Preferences > Package Settings > SublimeTextTrans > Settings - User`, it will open the user's custom preferences file for this plugin. 109 | 110 | There you can modify the transparency levels, by adding the following and adjusting the levels as you wish: 111 | 112 | 113 | { 114 | 115 | // If you like to have a different transparency level 116 | // modify this array of options in your user preferences 117 | // i.e. just add (copy/paste) this array and modify at wish 118 | // IMPORTANT: Level of opacity varies from 0 to 255 119 | // 0 = Totally transparent, 255 = Fully opaque 120 | "levels": [ 121 | 255, // Full opaque i.e not transparency - a.k.a Disabled 122 | 212, // Level 5 123 | 220, // Level 4 124 | 228, // Level 3 125 | 236, // Level 2 126 | 243 // Level 1 127 | ] 128 | } 129 | 130 | You can see other options on `Settings - Default` file. 131 | 132 | Author & Contributors 133 | ---------------------- 134 | - [@vhanla](https://github.com/vhanla) - Author. 135 | - [@rexdf](https://github.com/rexdf) - Contributor 136 | 137 | License 138 | ------- 139 | The MIT License (MIT) 140 | 141 | 142 | 143 | Copyright (c) 2013 Victor Alberto Gil 144 | 145 | 146 | 147 | Permission is hereby granted, free of charge, to any person obtaining a copy of 148 | this software and associated documentation files (the "Software"), to deal in 149 | the Software without restriction, including without limitation the rights to 150 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 151 | the Software, and to permit persons to whom the Software is furnished to do so, 152 | subject to the following conditions: 153 | 154 | The above copyright notice and this permission notice shall be included in all 155 | copies or substantial portions of the Software. 156 | 157 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 159 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 160 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 161 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 162 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 163 | -------------------------------------------------------------------------------- /SublimeTrans.py: -------------------------------------------------------------------------------- 1 | ''' 2 | ############################################################### 3 | # Plugin to adjust window's transparency under Windows OS # 4 | # compatible with Sublime Text 2 and Sublime Text 3 # 5 | # written by vhanla (https://profiles.google.com/vhanla) # 6 | ############################################################### 7 | ''' 8 | 9 | import os, sublime, sublime_plugin, platform, subprocess, sys 10 | 11 | from ctypes import * 12 | if sublime.platform() == 'windows': 13 | from ctypes import wintypes 14 | from ctypes import windll 15 | 16 | if sys.version_info < (3,): 17 | from transparency.commands import * 18 | else: 19 | import sublime_api 20 | from .transparency.commands import * 21 | 22 | STT_VERSION = "1.5" 23 | #default global variables , needed to use plugin_loaded function in order to work on ST3 24 | stt_settings_filename = "SublimeTextTrans.sublime-settings" 25 | stt_settings = None 26 | if sublime.platform() == 'linux': 27 | stt_about_message = ("SublimeTextTrans plugin v%s\n" 28 | "for Sublime Text 2 & Sublime Text 3 & 4\n" 29 | "Requires: wmctrl & xprop installed\n" 30 | "Package Name: Transparency\n" 31 | "Description: It will make Sublime Text transparent.\n\n" 32 | "Written by Victor Alberto Gil \n" 33 | "https://github.com/vhanla/SublimeTextTrans") % (STT_VERSION) 34 | elif sublime.platform() == 'windows': 35 | stt_about_message = ("SublimeTextTrans plugin v%s\n" 36 | "for Sublime Text 2 & Sublime Text 3 & 4\n" 37 | "Requires: SetSublimeLayered.exe (included)\n" 38 | "Package Name: Transparency\n" 39 | "Description: It will make Sublime Text transparent.\n\n" 40 | "Written by Victor Alberto Gil \n" 41 | "https://github.com/vhanla/SublimeTextTrans") % (STT_VERSION) 42 | stt_opacity = 0 43 | stt_autoapply = False 44 | stt_level0 = 0 45 | stt_level1 = 0 46 | stt_level2 = 0 47 | stt_level3 = 0 48 | stt_level4 = 0 49 | stt_level5 = 0 50 | exe_file = "" 51 | sublime_3 = True 52 | 53 | if sublime.platform()=='windows': 54 | 55 | SetLayeredWindowAttributes = windll.user32.SetLayeredWindowAttributes 56 | SetLayeredWindowAttributes.restype = wintypes.BOOL 57 | SetLayeredWindowAttributes.argtypes = [ 58 | wintypes.HWND, 59 | wintypes.COLORREF, 60 | wintypes.BYTE, 61 | wintypes.DWORD 62 | ] 63 | 64 | GetWindowLong = windll.user32.GetWindowLongA 65 | GetWindowLong.restype = wintypes.LONG 66 | GetWindowLong.argtypes = [ 67 | wintypes.HWND, 68 | wintypes.DWORD 69 | ] 70 | 71 | GetDesktopWindow = windll.user32.GetDesktopWindow 72 | GetDesktopWindow.restype = wintypes.HWND 73 | GetDesktopWindow.argtypes = None 74 | 75 | GetWindow = windll.user32.GetWindow 76 | GetWindow.restype = wintypes.HWND 77 | GetWindow.argtypes = [ 78 | wintypes.HWND, 79 | wintypes.UINT 80 | ] 81 | 82 | GetClassName = windll.user32.GetClassNameA 83 | GetClassName.restype = wintypes.INT 84 | GetClassName.argtypes = [ 85 | wintypes.HWND, 86 | wintypes.LPSTR, 87 | wintypes.INT 88 | ] 89 | 90 | IsWindowVisible = windll.user32.IsWindowVisible 91 | IsWindowVisible.restype = wintypes.BOOL 92 | IsWindowVisible.argtypes = [ 93 | wintypes.HWND 94 | ] 95 | 96 | ShellExecute = windll.shell32.ShellExecuteW 97 | ShellExecute.restype = wintypes.HINSTANCE 98 | ShellExecute.argtypes = [ 99 | wintypes.HWND, 100 | c_wchar_p, 101 | c_wchar_p, 102 | c_wchar_p, 103 | c_wchar_p, 104 | wintypes.INT 105 | ] 106 | 107 | GWL_EXSTYLE = -20 108 | LWA_ALPHA = 0x00000002 109 | GW_CHILD = 5 110 | GWL_HWNDPARENT = -8 111 | GW_HWNDNEXT = 2 112 | WS_EX_LAYERED = 0x00080000 113 | SW_HIDE = 0 114 | SW_SHOW = 5 115 | PROCESS_QUERY_INFORMATION = 0x0400 116 | PROCESS_VM_READ = 0x0010 117 | 118 | def sublime_opacity(opacity): 119 | if stt_settings is None: 120 | return 121 | 122 | if sublime_3: 123 | wndLst = [sublime.Window(hwnd) for hwnd in sublime_api.windows()] 124 | for wnd in wndLst: 125 | LHDesktop = GetDesktopWindow() 126 | LHWindow = wnd.hwnd() 127 | wl = GetWindowLong(LHWindow,GWL_EXSTYLE) 128 | try: 129 | if((wl & WS_EX_LAYERED) != WS_EX_LAYERED): 130 | parametro = str(LHWindow)+' '+ str(wl) 131 | ShellExecute(LHDesktop,"open", exe_file,parametro,None,SW_HIDE) 132 | 133 | if opacity is not None: 134 | SetLayeredWindowAttributes(LHWindow,0,opacity, LWA_ALPHA) 135 | cur_opacity = stt_settings.get("opacity", None) 136 | if cur_opacity != opacity: 137 | stt_settings.set("opacity", opacity) 138 | persist_settings() 139 | except ValueError: 140 | print("Error! ") 141 | else: 142 | #LHDesktop = GetDesktopWindow(None) 143 | LHDesktop = GetDesktopWindow() 144 | LHWindow = GetWindow(LHDesktop,GW_CHILD) 145 | Clase = 'PX_WINDOW_CLASS' 146 | while(LHWindow != None): 147 | LHParent = GetWindowLong(LHWindow, GWL_HWNDPARENT) 148 | clas = create_string_buffer(255) 149 | GetClassName(LHWindow,clas,255) 150 | classs = clas.value 151 | if IsWindowVisible(LHWindow): 152 | if (LHParent==0) or (LHParent==LHDesktop): 153 | if(classs==b'PX_WINDOW_CLASS'): 154 | #print('Applying opacity level ',opacity) 155 | wl = GetWindowLong(LHWindow,GWL_EXSTYLE) 156 | try: 157 | if((wl & WS_EX_LAYERED) != WS_EX_LAYERED): 158 | parametro = str(LHWindow)+' '+ str(wl) 159 | ShellExecute(LHDesktop,"open", exe_file,parametro,None,SW_HIDE) 160 | 161 | if opacity is not None: 162 | SetLayeredWindowAttributes(LHWindow,0,opacity, LWA_ALPHA) 163 | cur_opacity = stt_settings.get("opacity", None) 164 | if cur_opacity != opacity: 165 | stt_settings.set("opacity", opacity) 166 | persist_settings() 167 | break 168 | except ValueError: 169 | print("Error! ") 170 | 171 | LHWindow = GetWindow(LHWindow, GW_HWNDNEXT) 172 | 173 | # ------------------------------------------------- 174 | # Linux-specific definitions using wmctrl and xprop 175 | # ------------------------------------------------- 176 | elif sublime.platform() == 'linux': 177 | 178 | def sublime_opacity(opacity): 179 | try: 180 | # The command below finds all windows with "Sublime Text" in the title 181 | # Adjust the grep pattern if needed 182 | opacity2 = int(opacity/255*100) 183 | cmd = ( 184 | "for W in $(wmctrl -lx | grep 'sublime_text.Sublime_text' | awk '{{print $1}}'); do " 185 | "xprop -id $W -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY " 186 | "$(printf 0x%x $((0xffffffff * {} / 100))); " 187 | "done" 188 | ).format(opacity2) 189 | subprocess.call(["bash", "-c", cmd]) 190 | cur_opacity = stt_settings.get("opacity", None) 191 | if cur_opacity != opacity: 192 | stt_settings.set("opacity", opacity) 193 | persist_settings() 194 | except Exception as e: 195 | print("Error setting opacity on Linux:", e) 196 | 197 | # Other OS 198 | else: 199 | def sublime_opacity(opacity): 200 | pass 201 | 202 | # ------------------------------------ 203 | # Common functions and command classes 204 | # ------------------------------------ 205 | 206 | def sublime_opaque(level): 207 | global stt_opacity 208 | if not stt_opacity == level: 209 | stt_opacity = level 210 | sublime_opacity(stt_opacity) 211 | 212 | 213 | class SetOpacityHalfCommand(sublime_plugin.WindowCommand): 214 | def run(self): 215 | reload_settings() #update with user settings, incase user settings was changed 216 | sublime_opaque(stt_level1) 217 | def is_checked(self): 218 | return stt_opacity == stt_level1 219 | 220 | class SetOpacitySixCommand(sublime_plugin.WindowCommand): 221 | def run(self): 222 | reload_settings() #update with user settings, incase user settings was changed 223 | sublime_opaque(stt_level2) 224 | def is_checked(self): 225 | return stt_opacity == stt_level2 226 | 227 | class SetOpacitySevenCommand(sublime_plugin.WindowCommand): 228 | def run(self): 229 | reload_settings() #update with user settings, incase user settings was changed 230 | sublime_opaque(stt_level3) 231 | def is_checked(self): 232 | return stt_opacity == stt_level3 233 | 234 | class SetOpacityEightCommand(sublime_plugin.WindowCommand): 235 | def run(self): 236 | reload_settings() #update with user settings, incase user settings was changed 237 | sublime_opaque(stt_level4) 238 | def is_checked(self): 239 | return stt_opacity == stt_level4 240 | 241 | class SetOpacityNineCommand(sublime_plugin.WindowCommand): 242 | def run(self): 243 | reload_settings() #update with user settings, incase user settings was changed 244 | sublime_opaque(stt_level5) 245 | def is_checked(self): 246 | return stt_opacity == stt_level5 247 | 248 | class SetOpacityCommand(sublime_plugin.WindowCommand): 249 | def run(self): 250 | reload_settings() #update with user settings, incase user settings was changed 251 | sublime_opaque(stt_level0) 252 | def is_checked(self): 253 | return stt_opacity == stt_level0 254 | 255 | class SubTransAbout(sublime_plugin.WindowCommand): 256 | def run(sef): 257 | sublime.message_dialog(stt_about_message) 258 | 259 | class SublimeTextTransListener(sublime_plugin.EventListener): 260 | #these for ST3 only 261 | def on_new_async(self, view): 262 | if stt_autoapply: 263 | sublime_opacity(stt_opacity) 264 | #let's insist twice, specially for new sublime's window instance 265 | sublime.set_timeout(sublime_opacity(stt_opacity), 250) 266 | sublime.set_timeout(sublime_opacity(stt_opacity), 500) 267 | 268 | def on_activated_async(self, view): 269 | if stt_autoapply: 270 | sublime_opacity(stt_opacity) 271 | # there is no async method on ST2 272 | def on_new(self, view): 273 | if stt_autoapply and not sublime_3: 274 | sublime_opacity(stt_opacity) 275 | 276 | # this event works on ST2. Delayed "hack" in plugin_loaded is only for ST3 277 | def on_load(self, view): 278 | if stt_autoapply and not sublime_3: 279 | sublime_opacity(stt_opacity) 280 | 281 | def on_clone(self, view): 282 | if stt_autoapply and not sublime_3: 283 | sublime_opacity(stt_opacity) 284 | 285 | def on_activated(self, view): 286 | if stt_autoapply and not sublime_3: 287 | sublime_opacity(stt_opacity) 288 | 289 | def reload_settings(): 290 | #opacity levels 291 | global stt_level0, stt_level1, stt_level2, stt_level3, stt_level4, stt_level5 292 | global stt_settings_filename, stt_settings, sublime_3 293 | global stt_opacity 294 | global stt_autoapply 295 | # print ("Notice: Load/Reload settings incase user modified") 296 | stt_settings = sublime.load_settings(stt_settings_filename) 297 | stt_opacity = int(stt_settings.get('opacity',255)) 298 | stt_autoapply = bool(stt_settings.get('autoapply',False)) 299 | stt_levels = stt_settings.get('levels', [255, 212, 220, 228, 236, 243]) 300 | 301 | stt_level0 = int(stt_levels[0]) 302 | stt_level1 = int(stt_levels[1]) 303 | stt_level2 = int(stt_levels[2]) 304 | stt_level3 = int(stt_levels[3]) 305 | stt_level4 = int(stt_levels[4]) 306 | stt_level5 = int(stt_levels[5]) 307 | 308 | def plugin_loaded(): 309 | #print('Loading settings...') 310 | #Load settings 311 | reload_settings() 312 | 313 | if sublime.platform() == 'windows': 314 | #Python fails calling SetWindowLong from Windows and crashes the entire Sublimetext, 315 | #so we will use an exe file to set layered mode the sublimetext running app 316 | lib_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)),'lib') 317 | has_lib = os.path.exists(lib_folder) 318 | global exe_file 319 | exe_file = os.path.join(lib_folder,'SetSublimeLayered.exe') 320 | has_exe = os.path.exists(exe_file) 321 | if os.name == 'nt' and (not has_lib or not has_exe): 322 | sublime.error_message(u'SetSublimeLayered.exe is not found!') 323 | if stt_autoapply: 324 | sublime_opacity(stt_opacity) 325 | sublime.set_timeout(focus_active_view, 250) 326 | elif sublime.platform() == 'linux': 327 | if stt_autoapply: 328 | sublime_opacity(stt_opacity) 329 | 330 | #print('Done!') 331 | 332 | def plugin_unloaded(): 333 | #restore opacity on plugin unloaded/uninstalled 334 | sublime_opacity(255) 335 | 336 | 337 | # This delayed procedure will change focused view and call sublime_opacity 338 | # in order to apply on sublime's startup 339 | def focus_active_view(): 340 | winds = sublime.active_window() 341 | if winds: 342 | fview = winds.views() 343 | aview = winds.active_view() 344 | if fview and aview: 345 | # focus to the first view 346 | winds.focus_view(fview[0]) 347 | # return to the initial active view 348 | winds.focus_view(aview) 349 | #try again "hack" for ST3 350 | sublime_opacity(stt_opacity) 351 | 352 | def persist_settings(): 353 | sublime.save_settings(stt_settings_filename) 354 | 355 | if sys.version_info < (3,): 356 | sublime_3 = False 357 | plugin_loaded() --------------------------------------------------------------------------------