From 2c3cf5179f16e8303ece57e3dbb191a46f3dcb85 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 4 Oct 2014 16:59:06 +0200 Subject: Moved resources to the blog site --- content/resources/mymenu.lua | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 content/resources/mymenu.lua (limited to 'content/resources/mymenu.lua') diff --git a/content/resources/mymenu.lua b/content/resources/mymenu.lua new file mode 100644 index 0000000..b3e5be4 --- /dev/null +++ b/content/resources/mymenu.lua @@ -0,0 +1,67 @@ +-- Menu d'application + +local awbeautiful = require("beautiful") +local awful = require("awful") +local capi = { + screen = screen, +} + +local function getStickyIcon(client) + if client.sticky then + return awbeautiful.get().titlebar_sticky_button_focus_active + end + return awbeautiful.get().titlebar_sticky_button_focus_inactive +end + +local function getOnTopIcon(client) + if client.ontop then + return awbeautiful.get().titlebar_ontop_button_focus_active + end + return awbeautiful.get().titlebar_ontop_button_focus_inactive +end + +function newAppMenu(client) + local data = {} + local myAppMenu = {} + + local args = {} + args.keygrabber = true + + -- Insert the ontop entry + -- When onTop is selelected, set in floating mode too + table.insert(myAppMenu, {"On Top", function() + -- We do not use floating.togle() but syncronize the floating on top value + awful.client.floating.set( client, not client.ontop ) + client.ontop = not client.ontop + end , getOnTopIcon(client)} ) + + -- Insert the Sticky entry + table.insert(myAppMenu, {"Sticky", function() client.sticky = not client.sticky end , getStickyIcon(client)} ) + + -- Insert the Hide entry + if not client.minimized then + table.insert(myAppMenu, {"Minimize", function() client.minimized = true end } ) + end + table.insert(myAppMenu, {"Close", function() client:kill() end, awbeautiful.get().titlebar_close_button_focus } ) + + -- Add the move to tag entry + local moveToTag = {} + local tags = capi.screen[1]:tags() + for i = 1, #tags do + -- We do not show the curent client tags + local isInTag = false + local clientTag = tags[i]:clients() + for j = 1, #clientTag do + isInTag = isInTag or clientTag[j] == client + end + if not isInTag then + table.insert(moveToTag, {tags[i].name, function() awful.client.movetotag(tags[i], client) end } ) + end + end + table.insert(myAppMenu, {"Move To", moveToTag } ) + + data.menu = awful.menu.new( { items = myAppMenu} ) + data.menu:show(args) + + return data +end -- cgit v1.2.3