Hi there,

The first patch makes a few properties public again (since they became local after 5.2 rewrite) and removes some unnecessary context initializers.

The second one allows to specify the parameters for the menubar prompt. It was handy for me to specify a custom color for bg_cursor since my default bg_color is PNG image and that is not handled gracefully by awful.prompt.

Kind regards,

--
Alexander Yakushev

"If or if-not. There is no try..catch-based flow control in Clojure."
-- Master Joda

>From 33287719c9062057562dfa7607b1c4f59829cbf0 Mon Sep 17 00:00:00 2001
From: Alexander Yakushev <yakushev.a...@gmail.com>
Date: Tue, 4 Sep 2012 02:48:03 +0300
Subject: [PATCH 1/2] menubar: Make some parameters configurable again

After the rewrite from modules they ended up being local, but should
be available to user externally.
Also remove unnecessary local context bindings.

Signed-off-by: Alexander Yakushev <yakushev.a...@gmail.com>
---
 lib/menubar/init.lua.in | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index 7f917ed..05a7df7 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -15,15 +15,6 @@ local common = require("awful.widget.common")
 local theme = require("beautiful")
 local wibox = require("wibox")
 
--- Standard lua
-local pairs = pairs
-local ipairs = ipairs
-local table = table
-local tonumber = tonumber
-local string = string
-local math = math
-local setmetatable = setmetatable
-
 -- menubar
 local menubar = { mt = {} }
 menubar.menu_gen = require("menubar.menu_gen")
@@ -50,19 +41,19 @@ menubar.utils = require("menubar.utils")
 -- When true the .desktop files will be reparsed only when the
 -- extension is initialized. Use this if menubar takes much time to
 -- open.
-local cache_entries = true
+menubar.cache_entries = true
 
 -- When true the categories will be shown alongside application
 -- entries.
-local show_categories = true
+menubar.show_categories = true
 
 -- Specifies the geometry of the menubar. This is a table with the keys
 -- x, y, width and height. Missing values are replaced via the screen's
 -- geometry. However, missing height is replaced by the font size.
-local geometry = { width = nil,
-                   height = nil,
-                   x = nil,
-                   y = nil }
+menubar.geometry = { width = nil,
+                     height = nil,
+                     x = nil,
+                     y = nil }
 
 -- Private section
 local current_item = 1
@@ -137,7 +128,7 @@ local function menulist_update(query)
     -- command in the middle to the table match_inside.
 
     -- Add the categories
-    if show_categories then
+    if menubar.show_categories then
         for _, v in pairs(menubar.menu_gen.all_categories) do
             v.focused = false
             if not current_category and v.use then
@@ -258,13 +249,14 @@ function menubar.show(scr)
         initialize()
     elseif instance.wibox.visible then -- Menu already shown, exit
         return
-    elseif not cache_entries then
+    elseif not menubar.cache_entries then
         menubar.refresh()
     end
 
     -- Set position and size
     scr = scr or capi.mouse.screen or 1
     local scrgeom = capi.screen[scr].workarea
+    local geometry = menubar.geometry
     instance.wibox:geometry({x = geometry.x or scrgeom.x,
                              y = geometry.y or scrgeom.y,
                              height = geometry.height or theme.get_font_height() * 1.5,
-- 
1.7.12

>From 22eb543571f4a2e9d9614c4bede72bb9cb2bd041 Mon Sep 17 00:00:00 2001
From: Alexander Yakushev <yakushev.a...@gmail.com>
Date: Tue, 4 Sep 2012 02:45:18 +0300
Subject: [PATCH 2/2] menubar: Make prompt configurable

Add a parameter to configure menubar's prompt.

Signed-off-by: Alexander Yakushev <yakushev.a...@gmail.com>
---
 lib/menubar/init.lua.in | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index 05a7df7..a8d6fc2 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -55,6 +55,10 @@ menubar.geometry = { width = nil,
                      x = nil,
                      y = nil }
 
+-- Allows user to specify custom parameters for prompt.run function
+-- (like colors).
+menubar.prompt_args = {}
+
 -- Private section
 local current_item = 1
 local previous_item = nil
@@ -265,7 +269,10 @@ function menubar.show(scr)
     current_item = 1
     current_category = nil
     menulist_update()
-    awful.prompt.run({ prompt = "Run: " }, instance.prompt.widget,
+
+    local prompt_args = menubar.prompt_args or {}
+    prompt_args.prompt = "Run: "
+    awful.prompt.run(prompt_args, instance.prompt.widget,
                 function(s) end,            -- exe_callback function set to do nothing
                 awful.completion.shell,     -- completion_callback
                 awful.util.getdir("cache") .. "/history_menu",
-- 
1.7.12

Reply via email to