├── .gitignore ├── README.md ├── images └── icon.png ├── main.py ├── manifest.json ├── screenshots ├── apty.png └── icon.png └── versions.json /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | .cache 3 | .mypy_cache/ 4 | .idea/ 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Icon 3 |

4 | 5 |

APTy

6 | 7 | ---------- 8 | 9 | This is an extension for [ULauncher](https://ulauncher.io/), it helps you to search and install your APT package! 10 | 11 | | ![alt](screenshots/apty.png)| 12 | |-----------------------------| 13 | 14 | ## Options 15 | 16 | Type `apty` and start seach the package, when you select one you can press enter and your terminal 17 | will appear to install it! 18 | 19 | If you do Alt-Enter you will copy the package name to your clipboard. 20 | 21 | ## Terminal apps commands 22 | 23 | APTy needs a terminal configured to start the instalation, some examples: 24 | 25 | | Name | Command | 26 | |----------------|-------------------| 27 | | Gnome terminal | gnome-terminal -- | 28 | | Alacritty | alacritty -e | 29 | 30 | ## Attributions 31 | Icon from OpenMoji: https://openmoji.org/ 32 | 33 | ---------- 34 | 35 | If you like my work you can 36 | 37 | Buy Me A Coffee 38 | -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sergius02/ulauncher-apty/787a268ae3c51f054b8299d995ab4e480b06839d/images/icon.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import subprocess 3 | 4 | from ulauncher.api.client.EventListener import EventListener 5 | from ulauncher.api.client.Extension import Extension 6 | from ulauncher.api.shared.action.CopyToClipboardAction import CopyToClipboardAction 7 | from ulauncher.api.shared.action.RenderResultListAction import RenderResultListAction 8 | from ulauncher.api.shared.action.RunScriptAction import RunScriptAction 9 | from ulauncher.api.shared.event import KeywordQueryEvent 10 | from ulauncher.api.shared.item.ExtensionResultItem import ExtensionResultItem 11 | 12 | logger = logging.getLogger(__name__) 13 | 14 | 15 | class APTy(Extension): 16 | 17 | def __init__(self): 18 | super(APTy, self).__init__() 19 | self.subscribe(KeywordQueryEvent, KeywordQueryEventListener()) 20 | 21 | def search_package(self, query_package): 22 | results = [] 23 | 24 | if query_package == "": 25 | return [ 26 | ExtensionResultItem( 27 | icon="images/icon.png", 28 | name="Start typing the package name", 29 | description="Remember, you can use regular expresions\nFor example: apty ^steam", 30 | ) 31 | ] 32 | 33 | terminal_app = self.preferences.get("apty_terminal_app") 34 | max_results = int(self.preferences.get("apty_n_results")) 35 | 36 | data = subprocess.Popen(["apt-cache", "search", str(query_package)], stdout=subprocess.PIPE) 37 | query_results = str(data.communicate())\ 38 | .replace("(b\"", "")\ 39 | .replace("(b'", "")\ 40 | .replace("\\n', None)", "")\ 41 | .replace("\\n\", None)", "")\ 42 | .replace("', None)", "")\ 43 | .replace("\", None)", "") 44 | 45 | if query_results == "": 46 | return [ 47 | ExtensionResultItem( 48 | icon="images/icon.png", 49 | name="No package " + query_package + " could be found", 50 | description="Are your repositories updated? (sudo apt update)\n" 51 | "Remember, you can use regular expresions\nFor example: apty ^steam", 52 | ) 53 | ] 54 | 55 | packages = query_results.split("\\n") 56 | n_results = int(len(packages)) 57 | 58 | max_range = min(max_results, n_results) 59 | 60 | for i in range(int(max_range)): 61 | package = packages[i] 62 | package_name = package.split(" - ")[0] 63 | package_description = package.split(" - ")[1] 64 | results.append( 65 | ExtensionResultItem( 66 | icon="images/icon.png", 67 | name=package_name, 68 | description=package_description, 69 | on_enter=RunScriptAction('%s sudo apt install %s' % (terminal_app, package_name), []), 70 | on_alt_enter=CopyToClipboardAction(package_name) 71 | ) 72 | ) 73 | 74 | return results 75 | 76 | 77 | class KeywordQueryEventListener(EventListener): 78 | 79 | def on_event(self, event, extension): 80 | items = [] 81 | text = event.get_argument() or "" 82 | return RenderResultListAction(extension.search_package(text)) 83 | 84 | 85 | if __name__ == '__main__': 86 | APTy().run() 87 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "required_api_version": "^2.0.0", 3 | "name": "APTy", 4 | "description": "With APTy you can search and install APT package with your favourite terminal", 5 | "developer_name": "Sergio Fernández Celorio", 6 | "icon": "images/icon.png", 7 | "options": { 8 | "query_debounce": 0.05 9 | }, 10 | "preferences": [ 11 | { 12 | "id": "apty_search_keyword", 13 | "type": "keyword", 14 | "name": "Search", 15 | "default_value": "apty" 16 | }, 17 | { 18 | "id": "apty_terminal_app", 19 | "type": "input", 20 | "name": "Terminal app", 21 | "description": "This is the command to send your terminal emulator the apt install, see the Github for examples", 22 | "default_value": "gnome-terminal --" 23 | }, 24 | { 25 | "id": "apty_n_results", 26 | "type": "input", 27 | "name": "Max number of results", 28 | "default_value": "5" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /screenshots/apty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sergius02/ulauncher-apty/787a268ae3c51f054b8299d995ab4e480b06839d/screenshots/apty.png -------------------------------------------------------------------------------- /screenshots/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sergius02/ulauncher-apty/787a268ae3c51f054b8299d995ab4e480b06839d/screenshots/icon.png -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "required_api_version": "^2.0.0", "commit": "main" } 3 | ] 4 | --------------------------------------------------------------------------------