kspi / dmenu-frecency

A dmenu-based desktop application launcher
MIT License
33 stars 8 forks source link

Add app with name #13

Closed joksnet closed 9 years ago

joksnet commented 9 years ago

I would like to add a name to an application that I add manually.

For example, I open dmenu-frecency and type urxvt -e sh -c alsamixer. Can I change the name of this new application?

joksnet commented 9 years ago

Ok. I made a little patch to edit application names.

diff --git a/dmenu-frecency b/dmenu-frecency
index 795155e..afe7501 100755
--- a/dmenu-frecency
+++ b/dmenu-frecency
@@ -2,10 +2,11 @@
 """Dmenu launcher with history sorted by frecency.

 Usage:
-    dmenu-frecency [--read-apps]
+    dmenu-frecency [--read-apps] [--editor]

 Options:
     --read-apps         rereads all .desktop files.
+    --editor            enter editor mode
 """

 from docopt import docopt
@@ -266,6 +267,7 @@ class DmenuFrecency:

     def __init__(self, arguments):
         self.read_apps = arguments['--read-apps']
+        self.editor = arguments['--editor']
         self.load_config()
         self.state = LauncherState.load(self.config)
         assert self.state, "Failed to load state."
@@ -286,6 +288,15 @@ class DmenuFrecency:
             self.state.find_apps()
             self.state.clean_cache()
             self.state.save()
+            if not self.editor:
+                return
+
+        if self.editor:
+            for app, dates in self.state.visits.items():
+                app_name = input('Command `{}` [{}]: '.format(' '.join(app.command_line), app.name))
+                if app_name:
+                    app.name = app_name
+            self.state.save()
             return

         dmenu = Popen([self.config['dmenu']] + self.config['dmenu-args'], stdin=PIPE, stdout=PIPE)
kspi commented 9 years ago

To do that you should create a .desktop file for your app in in ~/.local/share/applications