-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17340d6
Showing
9 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pycache__ | ||
.cache | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<p align="center"> | ||
<img src="screenshots/icon.png" alt="Icon" /> | ||
</p> | ||
|
||
<h1 align="center">Color Converter</h1> | ||
|
||
---------- | ||
|
||
This is an extension for [ULauncher](https://ulauncher.io/), it helps you to convert RGB <> HEX color codes | ||
|
||
| ![alt](screenshots/tohex.png) | ![alt](screenshots/torgb.png) | | ||
|-------------------------------|-------------------------------| | ||
|
||
---------- | ||
|
||
## Options | ||
|
||
* tohex > Convert to Hex | ||
* torgb > Convert to RGB | ||
|
||
You can get the code to your clipboard, just select pressing enter! | ||
|
||
> **IMPORTANT!** Please, don't change the default keywords. | ||
> | ||
> **For the moment** the code has them hardcoded, so the extension cant work if you change it. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
import logging | ||
from ulauncher.api.client.Extension import Extension | ||
from ulauncher.api.client.EventListener import EventListener | ||
from ulauncher.api.shared.event import KeywordQueryEvent | ||
from ulauncher.api.shared.item.ExtensionResultItem import ExtensionResultItem | ||
from ulauncher.api.shared.action.RenderResultListAction import RenderResultListAction | ||
from ulauncher.api.shared.action.CopyToClipboardAction import CopyToClipboardAction | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HexCodeExtension(Extension): | ||
|
||
def __init__(self): | ||
super(HexCodeExtension, self).__init__() | ||
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener()) | ||
|
||
def toRGB(self, text): | ||
hex = text.replace("#","") | ||
rgb = tuple(int(hex[i:i+2], 16) for i in (0, 2, 4)).__str__() | ||
|
||
return [ | ||
ExtensionResultItem( | ||
icon='images/icon.png', | ||
name="#" + hex.upper(), | ||
description='HEX FORMAT', | ||
on_enter=CopyToClipboardAction("#" + hex.upper()) | ||
), | ||
ExtensionResultItem( | ||
icon='images/icon.png', | ||
name=rgb, | ||
description='RGB FORMAT', | ||
on_enter=CopyToClipboardAction(rgb) | ||
) | ||
] | ||
|
||
def toHex(self, text): | ||
rgb = text.replace("(","") | ||
rgb = rgb.replace(")","") | ||
rgb = rgb.replace(" ", "") | ||
|
||
rgbtuple = tuple(map(int, rgb.split(','))) | ||
|
||
hex = '%02x%02x%02x' % rgbtuple | ||
|
||
return [ | ||
ExtensionResultItem( | ||
icon='images/icon.png', | ||
name="#" + hex.upper(), | ||
description='HEX FORMAT', | ||
on_enter=CopyToClipboardAction("#" + hex.upper()) | ||
), | ||
ExtensionResultItem( | ||
icon='images/icon.png', | ||
name=rgb, | ||
description='RGB FORMAT', | ||
on_enter=CopyToClipboardAction(rgb) | ||
) | ||
] | ||
|
||
|
||
class KeywordQueryEventListener(EventListener): | ||
|
||
def on_event(self, event, extension): | ||
items = [] | ||
|
||
text = event.get_argument() or "" | ||
if event.get_keyword() == "tohex": | ||
return RenderResultListAction(extension.toHex(text)) | ||
|
||
if event.get_keyword() == "torgb": | ||
return RenderResultListAction(extension.toRGB(text)) | ||
|
||
return RenderResultListAction(items) | ||
|
||
if __name__ == '__main__': | ||
HexCodeExtension().run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"required_api_version": "^2.0.0", | ||
"name": "Color converter", | ||
"description": "Convert RGB <> Hex codes", | ||
"developer_name": "Sergio Fernández Celorio", | ||
"icon": "images/icon.png", | ||
"options": { | ||
"query_debounce": 0.05 | ||
}, | ||
"preferences": [{ | ||
"id": "color_converter_hex", | ||
"type": "keyword", | ||
"name": "toHex", | ||
"default_value": "tohex" | ||
}, | ||
{ | ||
"id": "color_converter_rgb", | ||
"type": "keyword", | ||
"name": "toRGB", | ||
"default_value": "torgb" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
{ "required_api_version": "^1.0.0", "commit": "python2" }, | ||
{ "required_api_version": "^2.0.0", "commit": "master" } | ||
] |