Skip to content

Commit

Permalink
Add J4DmenuDesktop extension
Browse files Browse the repository at this point in the history
  • Loading branch information
kynikos committed Apr 16, 2017
1 parent 98e4006 commit 0759afb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ qtile next_version:
!!! `extention` subpackage renamed to `extension` !!!
!!! `extentions` configuration variable changed to `extension_defaults` !!!
* features
- new RunCommand extension
- new RunCommand and J4DmenuDesktop extensions

qtile 0.10.7, released 2017-02-14:
* features
Expand Down
2 changes: 1 addition & 1 deletion libqtile/extension/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def safe_import(module_name, class_name):


safe_import("base", "RunCommand")
safe_import("dmenu", ["Dmenu", "DmenuRun"])
safe_import("dmenu", ["Dmenu", "DmenuRun", "J4DmenuDesktop"])
safe_import("window_list", "WindowList")
37 changes: 37 additions & 0 deletions libqtile/extension/dmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,40 @@ def __init__(self, **config):

def _configure(self, qtile):
Dmenu._configure(self, qtile)


class J4DmenuDesktop(Dmenu):
"""
Python wrapper for j4-dmenu-desktop
https://github.com/enkore/j4-dmenu-desktop
"""

defaults = [
("j4dmenu_command", 'j4-dmenu-desktop', "the dmenu command to be launched"),
("j4dmenu_use_xdg_de", False, "read $XDG_CURRENT_DESKTOP to determine the desktop environment"),
("j4dmenu_display_binary", False, "display binary name after each entry"),
("j4dmenu_generic", True, "include the generic name of desktop entries"),
("j4dmenu_terminal", None, "terminal emulator used to start terminal apps"),
("j4dmenu_usage_log", None, "file used to sort items by usage frequency"),
]

def __init__(self, **config):
Dmenu.__init__(self, **config)
self.add_defaults(J4DmenuDesktop.defaults)

def _configure(self, qtile):
Dmenu._configure(self, qtile)

self.configured_command = [self.j4dmenu_command, '--dmenu',
" ".join(shlex.quote(arg) for arg in self.configured_command)]
if self.j4dmenu_use_xdg_de:
self.configured_command.append("--use-xdg-de")
if self.j4dmenu_display_binary:
self.configured_command.append("--display-binary")
if not self.j4dmenu_generic:
self.configured_command.append("--no-generic")
if self.j4dmenu_terminal:
self.configured_command.extend(("--term", self.j4dmenu_terminal))
if self.j4dmenu_usage_log:
self.configured_command.extend(("--usage-log",
self.j4dmenu_usage_log))

0 comments on commit 0759afb

Please sign in to comment.