From b08d3caba89cd5d65c668f3f44cb96a58b94f71f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 15 Jul 2015 19:00:21 +0200 Subject: [PATCH] awful.widget.layoutbox: add tooltip with the layout's name Closes https://github.com/awesomeWM/awesome/pull/322. --- lib/awful/widget/layoutbox.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/awful/widget/layoutbox.lua b/lib/awful/widget/layoutbox.lua index ee6d2b79..2c0a698c 100644 --- a/lib/awful/widget/layoutbox.lua +++ b/lib/awful/widget/layoutbox.lua @@ -11,14 +11,16 @@ local setmetatable = setmetatable local ipairs = ipairs local button = require("awful.button") local layout = require("awful.layout") +local tooltip = require("awful.tooltip") local tag = require("awful.tag") local beautiful = require("beautiful") local imagebox = require("wibox.widget.imagebox") local layoutbox = { mt = {} } -local function update(w, screen) +local function update(w, screen, tooltip) local layout = layout.getname(layout.get(screen)) + tooltip:set_text(layout or "[no name]") w:set_image(layout and beautiful["layout_" .. layout]) end @@ -29,10 +31,12 @@ end function layoutbox.new(screen) local screen = screen or 1 local w = imagebox() - update(w, screen) + local tooltip = tooltip({ objects = {w}, delay_show = 1 }) + + update(w, screen, tooltip) local function update_on_tag_selection(t) - return update(w, tag.getscreen(t)) + return update(w, tag.getscreen(t), tooltip) end tag.attached_connect_signal(screen, "property::selected", update_on_tag_selection)