Giter Club home page Giter Club logo

dmenu-extended's Introduction

build:passed

dmenu-extended

An extension to the original dmenu allowing super fast access to your files, folders, and programs. dmenu-extended has support for plugins, command aliasing, file filtering, and customisation. You can also use dmenu-extended with rofi!.

See it in action

Dmenu-extended demo

Feature Summary:

  • Indexes the files and folders you specify
  • Built in support for plugins (internet search, sudo, system package management)
  • Systemd integration for cache automatic rebuilding
  • Ability to swap the menu to Rofi
  • Support for scanning alias files (e.g. .bashrc)

Installation

Dependencies

  • Python - version 3.6 or higher
  • dmenu - version 4.5 or later

Quick dependency install:

  • Ubuntu - sudo apt-get install suckless-tools
  • Arch - sudo pacman -S dmenu
  • Fedora - sudo dnf install dmenu

Install Method 1: PIP (recommended)

sudo pip3 install --upgrade dmenu_extended

Alternatively, omit sudo from the above command to install dmenu-extended only for the current user.

To uninstall dmenu-extended, run sudo pip3 uninstall dmenu_extended. Note that if dmenu-extended was installed without sudo (or root), the uninstall command should also be run without sudo (or root).

Install Method 2: Install from Source

Dependencies:

  • python3-setuptools

Clone this repository using git, or download the zip file and extract its contents. From within the extracted folder, either execute setup.sh or, execute the following commands manually:

Build the package with:

python3 -m build --wheel

Then to install the package, choose one of the following two options:

sudo pip3 install --upgrade dist/dmenu_extended-*-py3-none-any.whl

Alternatively, omit sudo from the above command to install dmenu-extended only for the current user.

Method 3: Install via AUR

An AUR package is available here: dmenu-extended-git.

Usage

Create a keybinding

Test that the new menu has been installed by running dmenu_extended_run from your terminal. NOTE: The first run will be slow as it is set to scan you home folder recursively to build the cache.

The most productive way to use dmenu-extended is to bind the command dmenu_extended_run to an easy to reach key combo. The way in which you do this will be different depending on your desktop environment but here is a brief list.

Ubuntu (Unity), Debian (Gnome), Mint (Cinnamon)

  1. Open System settings -> Keyboard -> Shortcuts
  2. Click Custom shortcuts and then the + (add custom shortcut) to add a new command
  3. Enter "dmenu_extended" as the name
  4. Enter "dmenu_extended_run" as the command and click apply
  5. Click next disabled (unassigned)
  6. Press the desired combination of keys (e.g. Alt+Enter)

Tiling window managers

If you use a tiling window manager, you may already have a key-combination bound to launch dmenu (i.e. Ctrl+P). Edit your window managers configuration file to launch dmenu_extended_run instead.

Advanced keybindings

dmenu_extended_run supports automated menu item selection via argument passing. If, for example, you frequently use the 'Internet Search' plugin with a particular search provider, you may want a binding that takes you directly to that provider. To do this you might bind the following command to an alternate key combination:

dmenu_extended_run "-> Internet search: " "Wikipedia"

The arguments must be written exactly as they would appear in the menu. Any number of arguments can be passed and each will be executed in the order they are passed. Each item represents one item selection from a menu. Remember to quote each item so they are passed to the menu correctly.

Configuration

Menu configuration is contained in a JSON formatted file found at ~/.config/dmenu-extended/config/dmenuExtended_preferences.txt that controls the appearance and functionality of the menu. This file is also accessible from the -> Menu configuration submenu as * Edit menu preferences

Functions of the items are as follows.

  • "valid_extensions" list of file extensions of files to include in the cache
  • "watch_folders" list of base paths to recursively search through for items to include
  • "follow_symlinks" boolean option controlling whether to follow a link while scanning
  • "ignore_folders" list of paths to be excluded from the cache
  • "global_ignore_folders" names of folders to exclude from cache (regardless of location)
  • "scan_hidden_folders" boolean value controlling whether to enter hidden folders when scanning
  • "include_hidden_files" boolean value controlling whether to include hidden files in the cache
  • "include_hidden_folders" boolean value controlling whether to include hidden folders in the cache
  • "include_items" list of extra items to include in the cache
  • "exclude_items" list of items to be excluded from the cache
  • "include_binaries" add items found in the system path
  • "filter_binaries" boolean that causes binaries not associated with destkop applications (those having a .desktop file) to be omitted from the cache (e.g. cp, mv)
  • "include_applications" add items found under /usr/share/applications
  • "alias_applications" alias applications with their intended names
  • "path_aliasFile" path to a file containing aliases (e.g. ~/.bash_aliases)
  • "abbreviate_homedir" abbreviate $HOME as ~ for files & folders
  • "frequently_used" the number of your most frequently used commands to show at the top of the menu
  • "alias_display_format" how to format aliased commands (e.g. "{name} ({command})")
  • "path_shellCommand" path to use for creating terminal helper script (e.g. "~/.dmenuEextended_shellCommand.sh")
  • "menu" executable to open the menu (dmenu)
  • "menu_arguments" list of parameters to launch the menu with
  • "fileopener" application to handle opening files
  • "filebrowser" application to handle opening folders
  • "webbrowser" application to handle opening urls (web browser)
  • "terminal" terminal emulator application
  • "terminal_editor" application used to edit files directly in the terminal
  • "indicator_submenu" symbol to indicate a submenu item in the cache
  • "indicator_edit" symbol to indicate an item will launch an editor in the cache
  • "indicator_alias" symbol to indicate an aliased command in the cache

Adding the item "" to "valid_extensions" will cause files with no extension to be included in the cache. Adding the item "*" to "valid_extensions" will cause all files to be included in the cache.

Rebuild the cache from terminal

It is possible to rebuild the cache from the terminal by running:

dmenu_extended_cache_build

You could run this script directly to rebuild your cache or call it from cron. Dmenu has systemd integration so you can set it rebuild your cache every 20 mins from the settings menu within dmenu-extended.

Background cache rebuild with Systemd

After installing dmenu-extended, a background updater service can be enabled. This will periodically update the cache in the background every 20 minutes. To install the background service, run:

dmenu_extended_install_systemd_service

Alternative intervals can be specified by passing the --interval-interval-mins [MINS] argument and specifying the interval in minutes. The service can then be enabled and disabled in the -> Settings menu of dmenu-extended.

Background cache rebuild with Incron

You can also rebuild the cache everytime a file or folder is being created, deleted or moved from or to the monitored path. Have Incron up and running. Edit your incrontab incrontab -e and add following line:

<PATH_TO_MONITOR>  IN_CREATE,IN_DELETE,IN_MOVE     <PATH_DMENU_EXTENDED_CACHE_BUILD>

Enter the path of dmenu_extended_cache_build, you can find this by running which dmenu_extended_cache_build. All paths must be absolute! Check out incrontab(5) for more event symbols.

Rebuild cache via pacman hook

You can update your application cache after installing/uninstalling a package via a pacman hook for immediate access/removal. Create a file /usr/share/libalpm/hooks/dmenu-cache-rebuild.hook:

[Trigger]
Type = Package
Operation = Install
Operation = Remove
Target = *

[Action]
Description = Rebuilds Cache of dmenu-extended after package installation or removal
When = PostTransaction
Exec = /usr/bin/sudo -u <USER> /usr/bin/dmenu_extended_cache_build
Depends = dmenu-extended-git

You need to execute the rebuild command via sudo -u <USER>, because pacman runs as root and would therefore not update userfiles.

Running Dmenu-extended with Rofi

Ensure you have Rofi installed and edit the following two configuration options as so:

"menu": "rofi",
"menu_arguments": [
  "-dmenu",
  "-i"
],

You may also need to add

"prompt": "Open",

to remove the extra colon depending on your Rofi version.

Advanced usage

Dmenu-extended understands the following modifier characters when entering a special command:

  1. + (plus) - Manually add an entry to the cache
  2. - (minus) - Remove a manually added entry from the cache
  3. : (colon) - Open with
  4. @ (at) - Open in default terminal editor
  5. ; (semi-colon) - Execute in terminal

These modifiers are entered into the menu; examples follow.

+ (plus) - Manually add an entry to the cache

If there is something you wish to run that isn't in the menu then you can add it by prepending with a +.

  • +htop; adds htop to the cache.
  • +libreoffice adds libreoffice to the cache.
  • +http://youtube.com adds a link to Youtube to the cache.

Once added these commands are stored in the preferences file (see general configuration) and will persist upon a rebuild of the cache. These items can also be manually edited within this file.

Built-in support for aliases

In addidion to adding items manually, dmenu_extended allows the addition of a more descriptive label for a stored command. For instance:

  • +htop;#View running processes displays as # View system processes (htop)
  • +libreoffice --writer#Writer displays as # Writer (libreoffice --writer)
  • +http://youtube.com#Youtube displays as # Youtube (http://www.youtube.com)

- (minus) - Remove a manually added entry from the cache

This applies to items that have previously saved to the store. If the item is not found in the store you will be given the chance to add it.

: (colon) - Open with

There are a few different ways to use the colon operator, summarised by example below. In these examples gedit is the name of a text editing application.

  • gedit: - Use gEdit to open a file. A list of all files and folders will be returned to select from.
  • gedit:.txt - Use gEdit to open a text file. A filtered list containing only text files will be shown to select from.
  • /home/me/Documents/writing.txt: - Open this file using... Returns a list of applications to launch the given file
  • /home/me/Documents/writing.txt:gedit - Open this file with gedit.
  • gedit:/home/me/Documents/writing.txt - Open this file with gedit.

@ (at) - Open in terminal editor

Suffix to open the chosen file inside the preferred editor in a terminal window. Default editor is set to vim, but it can be changed in the preferences ("terminal_editor"). The terminal window is closed as soon as the application is exited. For instance:

  • /home/me/Documents/writing.txt@

; (semi-colon) - Execute in terminal

Dmenu-extended doesn't know when the application you enter needs to be executed in a terminal window. To tell dmenu-extended to launch the following in a terminal, append a semi-colon to the end. Once the terminal program has exited the terminal will close.

For example,

  • htop; - Launches htop in a terminal window. Without the semi-colon nothing would happen.
  • alsamixer; - Launches the ALSA sound volume manager in a terminal. Without the semicolon nothing would happen.

Holding the terminal open on exit

By using two semicolons (;;) at the end of a command the terminal window will remain open once the executed command has completed. This is useful for running programs like inxi that exit on completion. You'll want to use this if you see your program flash up and disappear before you get a chance to see the output.

Loading an alias file

If you have an aliases file (for example ~/.bash_aliases or ~/.zsh_aliases) that you would like loaded into dmenu-extended, set it's path in the "path_aliasFile" field in of the preferences. Aliased items found in that file will show up in the menu once the cache has been rebuilt.

Controlling aliased command formatting

By default, all aliased commands are displayed prefixed without a prefix and no indication of the command being launched is given (for example ff). If you would prefer to have the aliased command appear with a prefix and some indication of what the command will launch (e.g. # ff (firefox)) - make the following alterations to your preferences file and rebuild the cache.

  • "indicator_alias": "" -> "indicator_alias": "#"
  • "alias_display_format": "{name}" -> "alias_display_format": "{name} ({command})"

Using a password helper for sudo commands

Password helper programs, such as zenity, can be used to prompt the user for a password outside of a terminal process whenever a password is required. Getting one setup requires creating a small bash script and configuration file. The following instructions step you through using zenity as the password helper program.

  1. Check you have zenity installed by running whereis zenity. You should see something like /usr/bin/zenity amongst other paths.
  2. Fill the password helper script sudo nano /usr/local/bin/zenity_askpass with:
#!/bin/bash
zenity --password --title="Sudo password prompt"
  1. Make the askpass script executable by running sudo chmod +x /usr/local/bin/zenity_askpass
  2. Create/edit the sudo configuration file sudo nano /etc/sudo.conf and make sure it contains the line Path askpass /usr/local/bin/zenity_askpass

Test the configuration by running a sudo command via dmenu-extended (e.g., sudo gedit). You should be prompted grapically for the password before the program opens.

Password manager screenshot

Contributing

Any sort of contribution is welcome, for example:

  • Helping out people who have Issues
  • Writing tests
  • Improving code
  • Writing plugins
  • Updating documentation

For those looking to improve the code, the code uses Black formatting on default settings. Pull-requests should be created with the same formatting. Only Python3 is currently supported, support for Python2 is being dropped.

Acknowledgements

dmenu-extended's People

Contributors

cestdiego avatar cjbassi avatar edi9999 avatar gokhankici avatar guiguid avatar luxcem avatar marczuo avatar markhedleyjones avatar mg979 avatar mkly avatar rafaelndev avatar samadamday avatar spamwax avatar spotlight0xff avatar testme115 avatar v1nc avatar vestingz avatar zappaboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dmenu-extended's Issues

Be able to use shell aliases

Hi,

Thank you for dmenu-extended, I love it.

Would it be possible to use shell aliases defined in a ~/.zsh_aliases file for dmenu-extended? I use zsh myself but bash would be fine to.

Best regards,
Markus Lindberg.

Running bash scripts with ";;" gives an error.

For example, I'm trying to run a script /colors.sh. I first add it to the cache and then attempt to run with "/colors.sh;;" from within dmenu_extended. This gives me the output

/home/username/.dmenuEextended_shellCommand.sh: line 2: -cd: command not found


Press enter to exit

The file dmenuEextended_shellCommand.sh contains

#! /bin/bash
-cd /home/username/colors.sh;
echo "

Press enter to exit";read var;

If I remove the "-cd " from line 1257 it seems to work fine.

As a side note dmenuEextended_shellCommand.sh was probably meant to be dmenuExtended_shellCommand.sh.

Bug in Proper Mapping of Aliases

Hi Mark,
I believe I found a bug in registering the mapping of aliases in the aliases_lookup.json, where if there is a formatting of alias (i.e. if I store them as # alias (command) ), then the alias wouldn't actually do anything. In fact, if I run it in a terminal, it would end with an error. I looked a bit further at the python code, and found the mistake (I think). The code for the function cache_build() (in the file dmenu_extended.py) has the lines

Lines 1062 - 1075

        if 'include_items' in self.prefs:
            include_items = []
            for item in self.prefs['include_items']:
                if type(item) == list:
                    if len(item) > 1:
                        aliased_items.append(self.format_alias(item[0], item[1]))
                        aliases.append([item[0], item[1]])
                    else:
                        if self.debug:
                            print("There are aliased items in the configuration with no command.")
                else:
                    include_items.append(item)
        else:
            include_items = []

I think the line aliases.append([item[0], item[1]]) should be replaced by aliases.append([self.format_alias(item[0], item[1]), item[1]])

I am not sure if the code you wrote is meant to be, and if I have done something wrong in setting up the aliases, but I still feel intuitively that the alias formatting should be in the code.

Btw, thanks for the great software. It's really great and makes a lot of things easier for many folks.

Have a nice day.

Problems with umlauts/other special characters

dmenu-extended correctly indexes files which names contain characters like ö, ä, ü, §, but seems to incorrectly pass those paths to xdg-open, so nothing happens when opening these files via dmenu-extended.

'desktop' entries do not open any more

I was running 56b9f6f for some time now and recently started pulling the new versions. I noticed desktop entries were not working any more; they just do not open.

I did a bisect, which points to 5aeafa3 :

5aeafa3f9f3cb4665a23d56b2a908afca1c48ef2 is the first bad commit
commit 5aeafa3f9f3cb4665a23d56b2a908afca1c48ef2
Author: Mark H. Jones <[email protected]>
Date:   Mon Jun 6 17:36:00 2016 +1200

    Rewrote adding and removing entry logic

:100755 100755 c401e08fe3cb609b6a61b9a86d0273b076258d17 4aac3bae58feb52f10c38225575e9ffe35c1e8b4 M  dmenu_extended.py

Spotify alias not working

Hello,

I just changed up my regular ol' dmenu to dmenu-extended, and I'm really liking it thus far!

One issue that I'm having is that my Spotify alias in my ~/.bashrc isn't being triggered for some reason. The alias itself is: alias spotify_hidpi='/usr/bin/spotify --force-device-scale-factor=2'

I've modified dmenuExtended_preferences.txt to point to my bashrc, and after updating the cache, the command spotify_hidpi does appear. However, nothing happens when I choose to run it - any idea why this might be happening?

FWIW, running spotify_hidpi in my gnome-terminal works as expected.

Thanks!

systemd service units and timer

@markjones112358
Are you sure your service units and timer are written correctly? They do not seem to work for me.

On my system, path to file is /usr/bin/dmenu_extended_cache_build, so I tried to use the system service unit, with systemsctl --user start update-dmenu-extended-db.system.service

Fails with various iterations of: Invalid user/group name or numeric ID:

Timer will not load since unit does not.

Are these working for you?

Edit: removing the line "User=%i" seems to do the trick (for the user unit).
I am either using the systemd-install.sh script wrong or it fails to insert the user name instead of %i in the unit file.

(In addition, I am not sure specifying the user is necessary in this case.)

But will look further into it and probably write my own service and timer files.

Fonts and size

With the latest commit dmenu doesn't seem to honor the value given in the config anymore, which worked fine before. I have terminus set as font and 12 as font size and neither font nor size seem to change from a set standard value no matter what I chose. It shows a different font and the a much too big size when I run dmenu-extended. I tried directly editing the value in the "dmenu_extended.py" file but that didn't do the trick either.

Donations?

Is there a way I can donate to this program? If so, please let me know here or through private message. I use this program everyday and it sames me an immense amount of time.

For example, I no longer have to use bash scripts for example to do basic things like launch a bunch programs. I just add them as aliases and it works great! I would love to donate.

Change Tab behaviour to jump to next hit instead of completion

Hi,

Currently, dmenu_extended applies the arrow keys to move to the next/previous completion after typing in part of the search term.

As a heavy vim user, this behaviour feels odd to me. My fingers are moved way too far from the middle keyboard row.

Is it possible to move to the next item with Tab instead of the arrow keys?

dmenu-extended doesn't honor Terminal=true in .desktop files?

Hello,
I have run into an issue.

Take the following .desktop file as an example

[Desktop Entry]
Type=Application
Name=ranger
Terminal=true
Exec=ranger
MimeType=inode/directory;

In a terminal, xdg-open ~ correctly opens ranger in my home directory.
If I run dmenu-extended from terminal (dmenu_extended_run) and pick a directory (say ~/Downloads), it is correctly opened in ranger in the same terminal where I ran dmenu_extended_run.
If i run dmenu-extended through an hotkey in i3, then this kind of programs that should run in terminal actually run in my login shell outside the X session, and I have to exit i3 to see them.

A small fix, however, makes it work as expected:

(In the desktop file)
Exec=urxvt -e ranger

Now, obviously, this isn't the correct way to fix it.

I have tested everything with vim instead of ranger, text files instead of directories, and it's the same.

EDIT: I am beginning to think that maybe the issue is not in dmenu-extended, but in xdg-open. Any thoughts?

ascii UnicodeDecodeError

First time executing dmenu_extended_run, I get:

Traceback (most recent call last):
  File "/usr/local/bin/dmenu_extended_run", line 11, in <module>
    dmenu_extended.run(debug)
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 1120, in run
    cache = d.cache_load()
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 510, in cache_load
    if self.cache_regenerate() == False:
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 477, in cache_regenerate
    cache = self.cache_build()
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 757, in cache_build
    for root, dirs , files in os.walk(watchdir, followlinks=follow_symlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 286, in walk
    if isdir(join(top, name)):
  File "/usr/lib/python2.7/posixpath.py", line 73, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb3 in position 1: ordinal not in range(128)

Can't build cache, utf-8 error

python3 -c "import dmenu_extended
  dmenu_extended.dmenu().cache_build()"
Setting up dmenu-extended prefs files...
Plugins directory exists - skipped
Cache directory exists - skipped
prefs directory exists - skipped
Existing preferences file found, will not overwrite.
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/usr/lib/python3.5/site-packages/dmenu_extended.py", line 850, in cache_build
    self.cache_save(foldernames, file_cache_folders)
  File "/usr/lib/python3.5/site-packages/dmenu_extended.py", line 504, in cache_save
    f.write(item+"\n")
  File "/usr/lib/python3.5/codecs.py", line 718, in write
    return self.writer.write(data)
  File "/usr/lib/python3.5/codecs.py", line 376, in write
    data, consumed = self.encode(object, self.errors)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcbf' in position 32: surrogates not allowed

Simple workaround is to catch exceptions in f.write(item+"\n"), but maybe it should be fixed anywhere else?

XDG Application Searching

Hello!

First of all: thank you for this brilliant project, it's just what I was looking for! It's elegant, powerful, and easy to use.

There is however one small problem for me. Because the list programs are determined by examining the binaries, some things which I'd like to launch are not immediately accessible (like LibreOffice, and Chrome for me (it lives inside a chroot)). Of course, one can easily manually add an entry to the cache, but this sort of thing can be done automatically if the application files (i.e. the .desktop files) are also scanned.

As it happens, I have already written the code for such a thing. I was in the process of making something similar to dmenu-extended (albeit a lot less powerful); you can find it here (it's not finished). I would very much like to add in this functionality and submit it as a pull request, but I feel I should consult with about one thing first: it requires the (non-standard-library) xdg python module.

It makes sense to me that you'd probably want to keep the number of dependencies to a minimum, so you might not think that it's worth requiring this extra module for the benefit it gives. Now, unfortunately the xdg module is licensed under the GNU license (see the repo here), so I can't just copy in the relevant bits of code (though, they aren't that complex, so it shouldn't be too much trouble to write them over again).

I'll probably fork the project and add my bits anyway, but I was wondering if this is something you'd like me to pull-request you?

(By the way, in the project I was working on, I also had a feature which allowed you to do 'acronym searching'; so "low" would match Libre Office Writer, for example. I would be very happy to code this in dmenu-extended, if you want.)

Thanks again!

Foreign characters in different encoding than utf-8 cause it to crash

When trying to add files which contain foreign characters in different encoding than utf-8, dmenu-extended simply crashes.
After some debugging I managed to identify the issue and remove the files.
It would be nice if dmenu-extended would ignore the files and print a warning, or at least print why and on which file it crashed.
Example of files which will cause it to crash:
http://www.serialzone.cz/download/titulky-serie/?sid=54&serie=2

Also including program output

Traceback (most recent call last):
File "/usr/bin/dmenu_extended_run", line 11, in
dmenu_extended.run(debug)
File "/usr/lib/python3.4/site-packages/dmenu_extended.py", line 1084, in run
cache = d.cache_load()
File "/usr/lib/python3.4/site-packages/dmenu_extended.py", line 501, in cache_load
if self.cache_regenerate() == False:
File "/usr/lib/python3.4/site-packages/dmenu_extended.py", line 468, in cache_regenerate
cache = self.cache_build()
File "/usr/lib/python3.4/site-packages/dmenu_extended.py", line 788, in cache_build
self.cache_save(foldernames, file_cache_folders)
File "/usr/lib/python3.4/site-packages/dmenu_extended.py", line 478, in cache_save
f.write(item+"\n")
File "/usr/lib/python3.4/codecs.py", line 711, in write
return self.writer.write(data)
File "/usr/lib/python3.4/codecs.py", line 368, in write
data, consumed = self.encode(object, self.errors)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udca1' in position 58: surrogates not allowed

FileNotFoundError on startup

Hi! I tried to start it, but an exception is thrown, I haven't had time to get into the code to check what could it be.

1424458230

I used the package in aur and master from this repo.

Thank you!

Background transparency

Hi!

Is it possible to use background transparency? If not, could this be implemented? Thanks in advance!

Why are you using /tmp/dmenuEextended_shellCommand.sh?

Hi,

So, I've seen that you are using /tmp/dmenuEextended_shellCommand.sh to execute commands with the terminal.
However, atleast on my system, it doesn't work :
I have no permission to execute that script, and any commands with ; or ;; at the end simply fail to execute.

Wouldn't it be easier to use ~/.dmenuExtended_Command.sh or something?

ls -l gives me that:
-rwxr-xr-x 1 yan yan 57 27.02.2015 00:19 dmenuEextended_shellCommand.sh*

Why is the Preferences a .txt if it's a json

dmenuExtended_preferences.txt is a json valid file, why does it have a .txt extension? also there are lot's of whitespace.

Thank you for this project, I'm loving it! :D I would also like to know if there is a guide to contribute plugins

dmenu-extended and rofi

@markjones112358

Is it possible to use dmenu-extended with rofi--but setting the number of lines somehow in the "menu_arguments" inside dmenuExtended_preferences.txt ?

I tried using this: "-theme-str '#listview { lines:20;}' -show drun" for example. This works on the cli but not as an argument inside the json file.

I also tried the simple "-lines 20" inside of "menu_arguments" either before or after "-dmenu" to no avail.

This feature would be helpful as I already run rofi as window switcher but only want just a few lines in that case.

OTOH, when using dmenu-extended, I want 20 lines or more (useful when scrolling through files). I have not found a way to have settings for opening rofi with a different number of lines (when using dmenu-extended) yet but it should be possible.

cache takes very long time with many dotfiles

I have a very huge amount of hidden files : about 400 000.

Caching the files takes an infinite time to complete (it is running for more than an hour now)

If I change the code like this by adding a print(root)

        for watchdir in watch_folders:
            for root, dirs , files in os.walk(watchdir, followlinks=follow_symlinks):
                dirs[:] = [d for d in dirs if os.path.join(root,d) not in ignore_folders]
                print(root)
                if self.prefs['scan_hidden_folders'] or root.find('/.')  == -1:
                    for name in files:
                        if self.prefs['include_hidden_files'] or name.startswith('.') == False:
                            if valid_extensions == True or os.path.splitext(name)[1].lower() in valid_extensions:
                                filenames.append(os.path.join(root,name))
                    for name in dirs:
                        if self.prefs['include_hidden_folders'] or name.startswith('.') == False:
                            foldernames.append(os.path.join(root,name) + '/')

I see that all files are parsed recursively.
I have 'scan_hidden_folders' set to false.

I think the problem comes from the fact that os.walk is recursive, so it can be very slow since it will open all files, even if they are hidden.

For example, it will open

/home/edgar/Documents/articles/.git/objects/3b
/home/edgar/Documents/articles/.git/objects/4a
/home/edgar/Documents/articles/.git/objects/4b
/home/edgar/Documents/articles/.git/objects/4c
/home/edgar/Documents/articles/.git/objects/4d
/home/edgar/Documents/articles/.git/objects/4e
/home/edgar/Documents/articles/.git/objects/4f

I think by using os.listdir(path) and doing the recursion inside python, we would get a huge performance benefit.

Directly calling cache_build leaves global variable d uninitialized

When following the instruction to create a python script to update the cache file:

#! /bin/python
import dmenu_extended
dmenu_extended.dmenu().cache_build()

Python returns error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/Development/dmenu-extended/dmenu_extended.py", line 952, in cache_build
    plugins = self.plugins_available()
  File "/home/user/Development/dmenu-extended/dmenu_extended.py", line 743, in plugins_available
    plugins = self.get_plugins(True)
  File "/home/user/Development/dmenu-extended/dmenu_extended.py", line 284, in get_plugins
    self.plugins_loaded = load_plugins(self.debug)
  File "/home/user/Development/dmenu-extended/dmenu_extended.py", line 195, in load_plugins
    plugins_loaded[0]['plugin'].launch_args = d.launch_args
AttributeError: 'NoneType' object has no attribute 'launch_args'

This is due to the fact that, without calling run(), the global variable d is uninitialized. I made a quick change to get around this issue, and it seems to be working so far, however I'm not sure if this'll not create any problems.

Folders with colon character

Folders containing the colon character (':') are not properly opened. Running it from a terminal throws an error message:

/home/user/Documents/Area: subject/
/home/user/Documents/Area: subject/
Traceback (most recent call last):
  File "dmenu_extended_run", line 7, in <module>
    dmenu_extended.run(*sys.argv)
  File "/home/user/bin/dmenu_extended.py", line 1850, in run
    d.execute(command)
  File "/home/user/bin/dmenu_extended.py", line 664, in execute
    return subprocess.call(command)
  File "/usr/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Thank you for your work!

Feature Request: Open specific file extension with a specific program

Hi

Your program has helped me a lot and I use it every day. I'm really thankful for that. I use ncmpcpp as the music player and vlc as the video player on my PC. Right now if I search for a song it will be played with vlc (I set "fileopener": "vlc") It would be great if we could open specific file extensions with specific programs. Perhaps you could add an option to do that in the config file ?

Most used at top

First of all, thank you for dmenu-extended it's awesome and very useful.

I was wondering if you'd consider pushing the most used commands at the top, even and especially when searching for a program, no matter how many times I pick it, the next time I search for it I will still have to go down a few places or write its more letter of its name.

Thanks

Rofi integration?

Just tried calling dmenu_extended.py as rofi mode (rofi -show dm -modi dm:~/git/dmenu_extended/dmenu_extended.py), which returns the following error: from: can't read /var/mail/__future__
Any ideas?

Can't build cache

python -c "import dmenu_extended

dmenu_extended.dmenu().cache_build()"
Setting up dmenu-extended prefs files...
Plugins directory exists - skipped
Cache directory exists - skipped
prefs directory exists - skipped
Existing preferences file found, will not overwrite.
Traceback (most recent call last):
File "", line 2, in
File "/usr/lib/python3.5/site-packages/dmenu_extended.py", line 668, in cache_build
applications = self.scan_applications()
File "/usr/lib/python3.5/site-packages/dmenu_extended.py", line 555, in scan_applications
for line in f.readlines():
File "/usr/lib/python3.5/codecs.py", line 706, in readlines
return self.reader.readlines(sizehint)
File "/usr/lib/python3.5/codecs.py", line 615, in readlines
data = self.read()
File "/usr/lib/python3.5/codecs.py", line 501, in read
newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd9 in position 22: invalid continuation byte

OSError: [Errno 2] No such file or directory on Ubuntu

Running dmenu-extended, latest git pull, on awesome in ubuntu 17.04

Getting this error.

$ dmenu_extended_run --debug
Debugging enabled
Launch arguments: []
Frequently used items cache does not exist, will return nothing
Opening cache at /home/user/.config/dmenu-extended/cache/dmenuExtended_plugins.txt
Opening cache at /home/user/.config/dmenu-extended/cache/dmenuExtended_all.txt
First menu closed with user input: Chromium Web Browser (chromium-browser)
Loading plugins
This command is not related to a plugin
Converting 'Chromium Web Browser (chromium-browser)' into its aliased command
Chromium Web Browser (chromium-browser)
No suitable candidate was found
Executing user input as a command
Executing: Chromium Web Browser (chromium-browser)
Command converted into:
[u'Chromium', u'Web', u'Browser', u'(chromium-browser)']
Traceback (most recent call last):
  File "/usr/local/bin/dmenu_extended_run", line 7, in <module>
    dmenu_extended.run(*sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 1844, in run
    handle_command(d, out)
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 1506, in handle_command
    d.execute(out)
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 649, in execute
    return subprocess.call(command)
  File "/usr/lib/python2.7/subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Can't access folders/files with characters like "ç, ã, é"

If I create a folder like "test" and add a file "test.pdf", the file is indexed and that's the normal behavior.
But if I create "test/testç.pdf", the file isn't indexed nor it appear on any cache file at .config/dmenu-extended/cache.
Also if I create "testç" and put the files "test.pdf" and "exampleç.pdf", even if the folder is recorded at dmenuExtended_folders.txt, the files are not.
Anyway I hope I'm being clear because english is not my mother language.
Thanks in advance!
PS: I use utf-8 scheme.

Directly search the internet

Hello,
Its great to see the new form of dmenu with added plugins. I really apreciate your work and I have been using it for my day to day life.
I was wonder if it is possible to directly search the internet with keybind. Currently, I have to run dmenu_extended_run and choose the third option with down key(which is far away) , select google and then search .. It will be nice if we can search directly with keybind like:

$ dmenu_extended_run --search google

Well, it will be really nice if you add the search result too in list format.

Thanking You
Subash

Aliasing not working

I put "~/.bashrc" as my path_aliasFile and it isn't registering my aliases. I have alias_applications set to true. What more is there to do?

{ "alias_applications": true, "alias_display_format": "{name}", "exclude_items": [], "filebrowser": "xdg-open", "fileopener": "xdg-open", "filter_binaries": true, "follow_symlinks": false, "frequently_used": 0, "ignore_folders": [], "include_applications": true, "include_binaries": true, "include_hidden_files": false, "include_hidden_folders": false, "include_items": [], "indicator_alias": "#", "indicator_edit": "*", "indicator_submenu": "->", "menu": "dmenu", "menu_arguments": [ "-b", "-i", "-nf", "#888888", "-nb", "#1D1F21", "-sf", "#ffffff", "-sb", "#1D1F21", "-fn", "terminus", "-l", "20" ], "path_aliasFile": "~/.bashrc", "path_shellCommand": "~/.dmenuEextended_shellCommand.sh", "prompt": "Open:", "scan_hidden_folders": false, "terminal": "xterm", "valid_extensions": [ "py", "svg", "pdf", "txt", "png", "jpg", "gif", "php", "tex", "odf", "ods", "avi", "mpg", "mp3", "lyx", "bib", "iso", "ps", "zip", "xcf", "doc", "docxxls", "xlsx", "md", "html", "sublime-project" ], "watch_folders": [ "~/" ], "webbrowser": "xdg-open" }

This is my dmenuExtended_preferences.txt. Should I change something within? Should I uninstall the old dmenu? All help is appreciated. Thanks.

History feature

In many line based programs (readline mostly), you can navigate the history of previous commands with Ctrl-p and Ctrl-n (or the arrow keys)

In dmenu-extended, I sometimes want to reexecute the same command that I executed last time.

Since arrow keys and Ctrl-p/Ctrl-n do the same thing (navigate between the choices), I propose that we use arrow keys for choice navigation and Ctrl-p/Ctrl-n for history navigation.

Would you be interested in implementing that ? If you don't have time to implement it, would you be accepting a merge request for that change. If yes, can you please pinpoint a bit where this change should be done ?

Thanks in advance !

How do I create plugins?

Hello,

Where can I find information on creating plugins?
I cant find the documentation anywhere.

Thanks

Store plugins in a repo + PackageManager patch

Storing the dmenu-extended plugins in gist seems less preferable than having them in a git repository, possibly even this repository.

On a related note, I made a slight change to the systemPackageManager plugin to enable refreshing the cache from a script without dmenu showing, diff viewable here:
https://gist.github.com/jebaum/ac6272c074a3afb37935/revisions

I can't send a pull request for gists though as far as I know.

Anyway, this mirrors the implementation of cache_regenerate in dmenu_extended.py, and allows for this script to refresh all caches (personally I have it as a cron job) in the background:

#!/usr/bin/python

import dmenu_extended
import os
import imp

dmenu_extended_pm_path = os.path.expanduser('~') + '/.config/dmenu-extended/plugins/dmenu_extended_systemPackageManager.py'

dmenu_extended_systemPackageManager = imp.load_source('dmenu_extended_systemPackageManager ', dmenu_extended_pm_path)

p = dmenu_extended_systemPackageManager.extension()
p.build_package_cache(message=False)

d = dmenu_extended.extension()
d.cache_regenerate(message=False)

Ability to Alias "Internet Search?"

I find that I often search using the Internet Search plugin, but I would ideally like to just type something like "g"(for google) and have it pop up. Is this possible currently? This may also have to do with the fact that things most used aren't near the top. I think a small cache of 100 items or so may be beneficial?

Ability to view (Aliased) Applications

I was comparing things and I noticed few missing Applications only to see that it's there (in binary) and it wasn't what I was expecting. I was wondering if that was expected behavior. I was expecting to see "minecraft" and "Minecraft (minecraft)"

If you have an (aliased) application that execs the same binary. (As the binary itself would...). Both of them will not be in the list ; only the binary will be.

For an exercise.... If you toggled "filter_binaries": true, you're expected to see (aliased) applications. What happened here is that we're seeing a mixed result -- Both (aliased) applications and certain binaries. I think it might be the unintended behavior of omitting / merging two things in your code to display less/repetative results.

URL's are being execute twice.

There is no sys.exit() after the line handling the URL's in run() (line 1156), so URL's are being processed by the following block starting at line 1213, resulting in the URL's being handled twice.

Unicode paths are not handled correctly

After waiting for sometime for the cache to be built, I get the following error :

Traceback (most recent call last):
  File "/usr/local/bin/dmenu_extended_cache_build", line 6, in <module>
    dmenu_extended.dmenu().cache_build()
  File "/usr/local/lib/python2.7/dist-packages/dmenu_extended.py", line 938, in cache_build
    for root, dirs , files in os.walk(foo, followlinks=follow_symlinks):
  File "/usr/lib/python2.7/os.py", line 296, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 286, in walk
    if isdir(join(top, name)):
  File "/usr/lib/python2.7/posixpath.py", line 73, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb4 in position 1: ordinal not in range(128)

It seems it is a known issue with os.walk : see this stackoverflow question : http://stackoverflow.com/questions/21772271/unicodedecodeerror-when-performing-os-walk

You can reproduce the issue locally by running the following in your shell:

touch  "$(echo -e ".abc\x8b\x8bThis is a bad filename")"
dmenu_extended_cache_build

Sudo plugin behavior

(running current GIT version under up-to-date Arch linux) While the instructions for using password helper work perfectly, using the Sudo plugin has an error immediately after typing Enter after typing the desired command target for 'sudo', e.g. 1) launch dmenu_extended_run, 2) choose the Sudo plugin, 3) type a program like 'gparted' which requires su 4) result: dmenu window closes.

Launching dmenu_extended_run in a terminal for the above yields:

`Traceback (most recent call last):

File "/usr/bin/dmenu_extended_run", line 7, in
dmenu_extended.run(*sys.argv)
File "/usr/lib/python3.6/site-packages/dmenu_extended.py", line 1546, in run
plugin_hook[0].run(out[len(plugin_hook[1]):].strip())
File "/home/paul/.config/dmenu-extended/plugins/plugin_sudo.py", line 63, in run
dmenu_extended.handle_command(self, item)
File "/usr/lib/python3.6/site-packages/dmenu_extended.py", line 1509, in handle_command
d.execute(out)
File "/usr/lib/python3.6/site-packages/dmenu_extended.py", line 649, in execute
return subprocess.call(command)
File "/usr/lib/python3.6/subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.6/subprocess.py", line 707, in init
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1333, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'SUDO_ASKPASS="/home/paul/.config/dmenu-extended/plugins/plugin_sudo.py" sudo -A '`

I don't have a good enough grasp of the py code to understand the cause of the error: the plugin_sudo.py file certainly exists and has +x permissions. Any ideas?

Aliases incorrectly attach themselves to directories

When I try to open a file in my ~/Dropbox directory, (anywhere under it, really) dmenu-extended opens the dropbox program. When I try to open a video in my ~/Videos directory, dmenu-extended opens the program called Videos (via the desktop file which calls it Videos in GNOME but is really Totem). Removing these aliases from the lookup table fixes it temporarily, but then the problem reappears each time the cache is rebuilt.

Only search .desktop files?

I would like to only be able to search only .desktop files, but it seems that they do not pick up properly. For instance, I have a google-chrome.desktop file and I set the flag in the desktop file to be --force-device-scale-factor=1.3(for my monitor). See here: https://major.io/2015/06/10/chrome-43-stuck-in-hidpi-mode/

If I launch this through xdg or through another window manager it picks up the settings, but it does not pick up the setting in dmenu extended.

Execute command in custom environment

I can't get my head around a way to launch a command through dmenu_extended using a specific environment variable like this: env $VAR= command. Neither defining an alias nor a wrapper script would work with dmenu. Any tips?

Ability to view/index hidden files

I discovered this gem today. I loved it. I wanted to know how I can add hidden directories / files to the indexing. That way, I can open the configuration files (with preferred/different editor) sometimes without using the terminal. Can we support this option? I do want the option to view/index the entire home directory if that's possible.

Changing window's size and exit key

Hello,

I recently started using dmenu-extended and I'm quite pleased with it! I've two questions however:

  • Is it possible to change the size of the window? By default, it seems to be half the vertical size of the screen. I would like to change this. Is it possible? (I find it too big);

  • Is it possible to make it so the shortcut to open dmenu-extended, closes it if it's already opened? I don't like having to type esc to close it;

  • Is it possible to change the position of the window? For example, change it to the top (instead of bottom), or to the mid of the screen..

Also, I find that there's slight delay in opening dmenu-extended after pressing the shortcut. It's a very small delay, but it's noticeable. Anything I can do to improve opening time?

Sorry for nitpicking! Dmenu-extended is awesome, thank you!

EDIT: I've managed to change the verical size of the window by changing one of the "menu-arguments".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.