Notify when clicking on launchbar icon

This commit is contained in:
Thomas Forgione 2017-07-30 12:34:20 +00:00
parent 4c5650ced0
commit 93b879710b
No known key found for this signature in database
GPG Key ID: 95D964F74A96119E
2 changed files with 52 additions and 2 deletions

View File

@ -0,0 +1,43 @@
-- INSPIRED FROM
---------------------------------------------------------------------------
-- @author Julien Danjou <julien@danjou.info>
-- @copyright 2008-2009 Julien Danjou
-- @classmod awful.widget.launcher
---------------------------------------------------------------------------
-- MODIFIED BY
-- thomas forgione
local setmetatable = setmetatable
local naughty = require('naughty')
local gtable = require("gears.table")
local spawn = require("awful.spawn")
local wbutton = require("awful.widget.button")
local button = require("awful.button")
local launcher = { mt = {} }
--- Create a button widget which will launch a command.
-- @param args Standard widget table arguments, plus image for the image path
-- and command for the command to run on click, or either menu to create menu.
-- @return A launcher widget.
function launcher.new(args)
if not args.callback and not args.menu then return end
local w = wbutton(args)
if not w then return end
local b
if args.callback then
b = gtable.join(w:buttons(), button({}, 1, nil, function () args.callback() end))
elseif args.menu then
b = gtable.join(w:buttons(), button({}, 1, nil, function () args.menu:toggle() end))
end
w:buttons(b)
return w
end
function launcher.mt:__call(...)
return launcher.new(...)
end
return setmetatable(launcher, launcher.mt)

View File

@ -8,7 +8,8 @@
local naughty = require('naughty')
local layout = require("wibox.layout")
local util = require("awful.util")
local launcher = require("awful.widget.launcher")
local spawn = require('awful.spawn')
local launcher = require("command_launcher")
local launchbar = {}
@ -46,7 +47,13 @@ function launchbar.new(filedir)
for f in files:lines() do
local t = io.open(f):read("*all")
table.insert(items, { image = find_icon(getValue(t,"Icon")),
command = getValue(t,"Exec"),
callback = function ()
naughty.notify({
title = "Starting " .. getValue(t, "Name"),
text = ""
})
spawn(getValue(t,"Exec"))
end,
position = tonumber(getValue(t,"Position")) or 255 })
end
table.sort(items, function(a,b) return a.position < b.position end)