Hello everybody,
I've sent these patches to Uli, but forgot to CC the list with my new
set of patches. Sorry. Here is the new batch.
Patch3 Add a visible selection to exec the query only if there are other
selections.
Patch4 should fix the Bug #993 as well.
Patch5 largely the same as before..
Patch6 should add some documentation to menubar, but I am not familiar
with luadoc, so it somehow does not work.
Patch7 is just an aesthetic change, which brings more order.. :)
All these patches work on my machine, so should work on yours as well.
Cheers,
Ignas A.
>From 83ec68e38070915a9656c3658b04668f5cfdab3d Mon Sep 17 00:00:00 2001
From: "Ignas Anikevicius (gns_ank)" <[email protected]>
Date: Fri, 4 May 2012 23:07:51 +0100
Subject: [PATCH 3/7] Menubar: 'Exec: ' item addition to the end.
This adds a 'Exec: <your-cmd-here>' item to the end of the list,
which appears only if there is at least one application entry in
the list. This is useful, when the program is not in the list of menubar
entries (e.g. it does not have a .desktop file).
When there is are no matching application entries, the 'Exec: ' item is
silently removed, as we already have the same in the prompt.
Signed-off-by: Ignas Anikevicius (gns_ank) <[email protected]>
---
lib/menubar/init.lua.in | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index 3e96c30..938471b 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -93,9 +93,6 @@ end
-- @param o The menu item.
-- @return if the function processed the callback, new awful.prompt command, new awful.prompt prompt text.
local function perform_action(o)
- if not o or o.empty then
- return true
- end
if o.key then
current_category = o.key
local new_prompt = shownitems[current_item].name .. ": "
@@ -158,13 +155,15 @@ local function menulist_update(query)
end
if #shownitems > 0 then
+ -- Insert a run item value as the last choice
+ table.insert(shownitems, { name = "Exec: " .. query, cmdline = query, icon = nil })
+
if current_item > #shownitems then
current_item = #shownitems
end
shownitems[current_item].focused = true
else
- table.insert(shownitems, { name = "<no matches>", icon = nil,
- empty = true })
+ table.insert(shownitems, { name = "", cmdline = query, icon = nil })
end
common.list_update(common_args.w, nil, label,
--
1.7.8.5
>From 921e9065bffe9a96e06712994a5677d14260f4a0 Mon Sep 17 00:00:00 2001
From: "Ignas Anikevicius (gns_ank)" <[email protected]>
Date: Fri, 4 May 2012 23:08:45 +0100
Subject: [PATCH 4/7] Menubar: Add navigation and execution keybindings.
This adds more navigation keybindings ('Home' and 'End'), which select
the first and the last entry from the list respectively. Also, it adds
two more keybindings:
'Ctrl+Enter' - Run the query (no need to press End and then
Enter)
'Ctrl+Alt+Enter' - Run query in the terminal (sometimes there are
terminal applications which one wants to run, e.g. ncmpcpp)
Signed-off-by: Ignas Anikevicius (gns_ank) <[email protected]>
---
lib/menubar/init.lua.in | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index 938471b..112c867 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -14,6 +14,7 @@ local awful = require("awful")
local common = require("awful.widget.common")
local theme = require("beautiful")
local menu_gen = require("menubar.menu_gen")
+local menu_utils = require("menubar.utils")
local wibox = require("wibox")
-- Standard lua
@@ -212,8 +213,22 @@ local function prompt_keypressed_callback(mod, key, comm)
current_item = previous_item
return true, nil, "Run app: "
end
+ elseif key == "Home" then
+ current_item = 1
+ return true
+ elseif key == "End" then
+ current_item = #shownitems
+ return true
elseif key == "Return" then
- return perform_action(shownitems[current_item])
+ if mod.Control then
+ current_item = #shownitems
+ if mod.Mod1 then
+ -- add a terminal to the cmdline
+ shownitems[current_item].cmdline = menu_utils.terminal
+ .. " -e " .. shownitems[current_item].cmdline
+ end
+ end
+ perform_action(shownitems[current_item])
end
return false
end
--
1.7.8.5
>From 433a42e69ceeff3d9b86760b84e41ad8e6131d15 Mon Sep 17 00:00:00 2001
From: "Ignas Anikevicius (gns_ank)" <[email protected]>
Date: Fri, 4 May 2012 23:09:03 +0100
Subject: [PATCH 5/7] Menubar: Add shell completion to menubar
Since we can search for commands in menubar and easily execute almost
any program now, we can definitely make use of awful.shell.completion,
which is enabled with this commit.
Signed-off-by: Ignas Anikevicius (gns_ank) <[email protected]>
---
lib/menubar/init.lua.in | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index 112c867..d51e4eb 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -255,10 +255,12 @@ function show(scr)
current_item = 1
current_category = nil
menulist_update()
- awful.prompt.run({ prompt = "Run app: " }, instance.prompt.widget, function(s) end,
- nil, awful.util.getdir("cache") .. "/history_menu", nil, hide,
- menulist_update,
- prompt_keypressed_callback)
+ awful.prompt.run({ prompt = "Run: " }, instance.prompt.widget,
+ function(s) end, -- exe_callback function set to do nothing
+ awful.completion.shell, -- completion_callback
+ awful.util.getdir("cache") .. "/history_menu",
+ nil, hide, menulist_update, prompt_keypressed_callback
+ )
instance.wibox.visible = true
end
--
1.7.8.5
>From 139361a42330c249bd6db807f3ac4e89d9d2e625 Mon Sep 17 00:00:00 2001
From: "Ignas Anikevicius (gns_ank)" <[email protected]>
Date: Sat, 5 May 2012 23:39:57 +0100
Subject: [PATCH 6/7] Menubar: document keybindings and some minor fixes
Signed-off-by: Ignas Anikevicius (gns_ank) <[email protected]>
---
lib/menubar/init.lua.in | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index d51e4eb..bdaa841 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -1,4 +1,17 @@
---------------------------------------------------------------------------
+-- Menubar shortcuts:
+-- <ul>
+-- <li>"Left" | "C-j" select an item on the left</li>
+-- <li>"Right" | "C-k" select an item on the right</li>
+-- <li>"Backspace" exit the current category if we are in any</li>
+-- <li>"Escape" exit the current directory or exit menubar</li>
+-- <li>"Home" select the first item</li>
+-- <li>"End" select the last</li>
+-- <li>"Return" execute the entry</li>
+-- <li>"C-Return" execute the command with awful.util.spawn</li>
+-- <li>"C-M-Return" execute the command in a terminal>
+-- </ul>
+--
-- @author Alexander Yakushev <[email protected]>
-- @copyright 2011-2012 Alexander Yakushev
-- @release @AWESOME_VERSION@
@@ -59,7 +72,7 @@ local instance = { prompt = nil,
local common_args = { w = wibox.layout.fixed.horizontal(),
data = setmetatable({}, { __mode = 'kv' }) }
--- Wrap the text with the color span tag.
+--- Wrap the text with the color span tag.
-- @param s The text.
-- @param c The desired text color.
-- @return the text wrapped in a span tag.
@@ -67,7 +80,7 @@ local function colortext(s, c)
return "<span color='" .. c .. "'>" .. s .. "</span>"
end
--- Generate a pattern matching expression that ignores case.
+--- Generate a pattern matching expression that ignores case.
-- @param s Original pattern matching expresion.
local function nocase (s)
s = string.gsub(s, "%a",
@@ -78,7 +91,7 @@ local function nocase (s)
return s
end
--- Get how the menu item should be displayed.
+--- Get how the menu item should be displayed.
-- @param o The menu item.
-- @return item name, item background color, background image, item icon.
local function label(o)
@@ -90,7 +103,7 @@ local function label(o)
end
end
--- Perform an action for the given menu item.
+--- Perform an action for the given menu item.
-- @param o The menu item.
-- @return if the function processed the callback, new awful.prompt command, new awful.prompt prompt text.
local function perform_action(o)
@@ -107,7 +120,7 @@ local function perform_action(o)
end
end
--- Update the menubar according to the command entered by user.
+--- Update the menubar according to the command entered by user.
-- @param query The text to filter entries by.
local function menulist_update(query)
local query = query or ""
@@ -172,7 +185,7 @@ local function menulist_update(query)
shownitems)
end
--- Create the menubar wibox and widgets.
+--- Create the menubar wibox and widgets.
local function initialize()
instance.wibox = wibox({})
instance.widget = get()
@@ -189,7 +202,7 @@ function refresh()
menu_entries = menu_gen.generate()
end
--- Awful.prompt keypressed callback to be used when the user presses a key.
+--- Awful.prompt keypressed callback to be used when the user presses a key.
-- @param mod Table of key combination modifiers (Control, Shift).
-- @param key The key that was pressed.
-- @param comm The current command in the prompt.
--
1.7.8.5
>From c00b817ec1b874c8bc791e74b179141543bce1ff Mon Sep 17 00:00:00 2001
From: "Ignas Anikevicius (gns_ank)" <[email protected]>
Date: Sat, 5 May 2012 23:43:33 +0100
Subject: [PATCH 7/7] Menubar: Shorten the prompt to just run
Signed-off-by: Ignas Anikevicius (gns_ank) <[email protected]>
---
lib/menubar/init.lua.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index bdaa841..4275368 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -218,13 +218,13 @@ local function prompt_keypressed_callback(mod, key, comm)
if comm == "" and current_category then
current_category = nil
current_item = previous_item
- return true, nil, "Run app: "
+ return true, nil, "Run: "
end
elseif key == "Escape" then
if current_category then
current_category = nil
current_item = previous_item
- return true, nil, "Run app: "
+ return true, nil, "Run: "
end
elseif key == "Home" then
current_item = 1
--
1.7.8.5