first draft of AWMTK2 and a test widget (dismal)

This commit is contained in:
Yessiest 2022-07-23 23:10:02 +04:00
parent bb9691da75
commit 0eb2c2ac43
69 changed files with 627 additions and 48 deletions

View File

@ -6,36 +6,64 @@ local beautiful = require("beautiful")
local awmtk = {}
-- {{{ Utils
awmtk.create_class = function(name,overrides,style,parent_class)
return setmetatable(overrides,{
awmtk.create_delta = function(name,instance_delta,class_delta,parent_delta)
-- To save memory, we create proxies for lower layers called "deltas"
-- This function creates that proxy layer using metatables
return setmetatable(instance_delta,{
__index = function(self,k)
-- Per-widget overrides are top priority
-- Per-instance overrides are top priority
if rawget(self,k) then
return rawget(self,k)
-- Style overrides are second in priority
elseif type(style[name]) == "table" and rawget(style[name],k) then
return rawget(style[name],k)
-- Parent class is fallback
elseif parent_class[k] then
return parent_class[k]
-- Class-wide overrides are second in priority
elseif type(class_delta[name]) == "table"
and rawget(class_delta[name],k) then
return rawget(class_delta[name],k)
-- Parent is fallback
elseif parent_delta[k] then
return parent_delta[k]
end
end
})
end
awmtk.create_style = function(style_name,parent,overrides)
awmtk.create_style = function(name,parent,overrides)
-- A style is essentially a layer of deltas upon the previous (parent) style
local new_style = {}
for name,parent_class in pairs(parent) do
new_style[name] = awmtk.create_class(
new_style[name] = awmtk.create_delta(
name,
(overrides and overrides[name]) or {},
(beautiful[style_name] or {}),
(beautiful.widgets and beautiful.widgets[style_name]) or {},
parent_class
)
end
return new_style
end
awmtk.create_template_lib = function(name,parent,overrides)
-- same thing but beautiful.templates
return awmtk.create_delta(
name,
overrides or {},
beautiful.templates or {},
parent
)
end
awmtk.build_templates = function(templates,style)
local new_templates = {}
for name,template in pairs(awmtk.templates) do
new_templates[name] = templates[name](style)
end
return new_templates
end
awmtk.merge = function(base,overrides)
for k,v in pairs(overrides) do
base[k] = v
end
return base
end
-- }}}
@ -54,26 +82,185 @@ awmtk.default = {
shape_border_color = beautiful.shape_border_color or beautiful.bg_normal,
-- }
-- { Shapes
inner_margin = beautiful.inner_margin or 5,
rounding = beautiful.rounding or 0,
margins = 5,
spacing = 5,
shape = function(cr, width, height)
return require("gears").shape.rounded_rect(cr,width,height,5)
end,
-- }
},{__index = beautiful})
}
-- Container subclass
awmtk.default.container = awmtk.create_class("container",{
-- Subclasses
awmtk.default.container = awmtk.create_delta("container",{
},awmtk.default,awmtk.default.base)
-- Button subclass
awmtk.default.button = awmtk.create_class("button",{
inner_margin = 1
awmtk.default.button = awmtk.create_delta("button",{
margins = 3
},awmtk.default,awmtk.default.base)
-- Icon subclass
awmtk.default.icon = awmtk.create_class("icon",{
inner_margin = 1
awmtk.default.icon = awmtk.create_delta("icon",{
margins = 1
},awmtk.default,awmtk.default.base)
awmtk.default.textbox = awmtk.create_delta("textbox",{
font = beautiful.font or "sans 8"
}, awmtk.default,awmtk.default.base)
awmtk.default.separator = awmtk.create_delta("separator",{
thickness = 1,
color = beautiful.bg_focus,
border_width = 0
}, awmtk.default,awmtk.default.base)
awmtk.default.article = awmtk.create_delta("article", {
icon_size = 16,
small_font = beautiful.font or "sans 8",
font_align = "left",
small_font_align = "left"
}, awmtk.default,awmtk.default.base)
awmtk.default.popup = awmtk.create_delta("popup", {
}, awmtk.default,awmtk.default.base)
-- }}}
-- {{{ Generic templates
awmtk.templates = {
-- Templates are built first using the given style, then applied to contents
-- through returned function
container = function(style)
return function(layout,options)
return awmtk.merge({
{
layout,
margins = (options and options.margins) or style.container.margins,
widget = wibox.container.margin
},
bg = style.container.bg_normal,
shape = style.container.shape,
widget = wibox.container.background
},options or {})
end
end,
button = function(style)
return function(layout,options)
return awmtk.merge({
{
layout,
margins = (options and options.margins) or style.button.margins,
widget = wibox.container.margin
},
bg = style.button.bg_normal,
shape = style.button.shape,
widget = wibox.container.background
},options or {})
end
end,
textbox = function(style)
return function(options)
return awmtk.merge({
font = style.textbox.font,
widget = wibox.widget.textbox
},options or {})
end
end,
hseparator = function(style)
return function(options)
awmtk.merge({
widget = wibox.widget.separator,
orientation = "horizontal",
thickness = style.separator.thickness,
color = style.separator.color,
border_width = style.separator.border_width
},options or {})
end
end,
vseparator = function(style)
return function(options)
awmtk.merge({
widget = wibox.widget.separator,
orientation = "vertical",
thickness = style.separator.thickness,
color = style.separator.color,
border_width = style.separator.border_width
},options or {})
end
end,
-- Article is a template that contains an icon, a headline and a
-- short description, side by side. Useful for menus and notifications.
article = function(style)
return function(options)
return awmtk.merge({
(options.icon and {
{
{
image = options.icon,
resize = options.resize,
widget = wibox.widget.imagebox
},
strategy = "exact",
height = options.icon_size or
style.article.icon_size,
width = options.icon_size or
style.article.icon_size,
widget = wibox.container.constraint
},
widget = wibox.container.place,
valign = "center",
halign = "center"
}),
{
{
markup = options.title or "",
widget = wibox.widget.textbox,
font = options.font or style.article.font,
align = options.font_align or
style.article.font_align,
valign = "center"
},
(options.description and {
markup = options.description,
widget = wibox.widget.textbox,
font = options.small_font or style.article.small_font,
align = options.small_font_align or
style.article.small_font_align,
valign = "center"
}),
spacing = style.article.spacing,
layout = wibox.layout.flex.vertical
},
spacing = style.article.spacing,
layout = wibox.layout.fixed.horizontal,
bg = style.article.bg_normal,
widget = wibox.container.background
}, options or {})
end
end,
popup = function(style)
return function(widget,options)
return awmtk.merge({
widget = {
{
widget,
margins = (options and options.margins) or style.popup.margins,
widget = wibox.container.margin
},
bg = style.popup.bg_normal,
widget = wibox.container.background
},
shape = style.popup.shape,
visible = false,
ontop = true
},options or {})
end
end
}
-- }}}
return awmtk

18
modules/autostart.lua Normal file
View File

@ -0,0 +1,18 @@
-- XFCE style autostart system
local awful = require("awful")
local gears = require("gears")
local gfs = gears.filesystem
local menu_utils = require("menubar.utils")
local stdir = "/tmp/.awesome_startup/"
gfs.make_directories(stdir)
awful.spawn.with_line_callback("find "..gfs.get_xdg_config_home().."autostart/ -name *.desktop",{
stdout = function(line)
local data = menu_utils.parse_desktop_file(line)
if (data.RunHook == "0") or (data.RunHook == nil) then
if not gfs.file_readable(stdir..line:match("[^/]*$")) then
io.open(stdir..line:match("[^/]*$"),"w"):close()
awful.spawn(data.Exec)
end
end
end
})

View File

@ -3,7 +3,16 @@
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
-- Global settings
global = {}
global.terminal = "xfce4-terminal" --Mod+Enter (spawn terminal)
global.browser = "prime-run librewolf" --Mod+Shift+Enter (spawn browser)
global.modkey = "Mod4" -- Default modifier key
global.theme = "default"
global.shell = "zsh"
awful.util.shell = global.shell
--error handling
if awesome.startup_errors then
print("Error during startup: "..awesome.startup_errors)
@ -18,14 +27,14 @@ do
end)
end
--theme
beautiful.init(gears.filesystem.get_themes_dir().."default/theme.lua")
--screen setup
awful.screen.connect_for_each_screen(function(s)
gears.wallpaper.maximized(root_path.."/background.jpg")
awful.tag({ "1" }, s, awful.layout.suit.floating)
end)
--theme initialization
beautiful.init(root_path.."/themes/"..global.theme.."/theme.lua")
--client mouse bindings
clientbuttons = gears.table.join(
@ -44,6 +53,8 @@ awful.rules.rules = {
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
placement = awful.placement.no_overlap+awful.placement.no_offscreen
}
}
@ -61,6 +72,13 @@ client.connect_signal("manage", function(c)
end
end)
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
end)
--screen setup
awful.screen.connect_for_each_screen(function(s)
awful.tag({ "1", "2", "3", "4" }, s, awful.layout.suit.floating)

View File

@ -1,7 +1,9 @@
-- Error logging module
local loghandler = io.open(os.getenv("HOME").."/.awesome_errors","w")
local naughty = require("naughty")
if awesome.startup_errors then
loghandler:write("[STARTUP] "..tostring(awesome.startup_errors).."\n")
naughty.notify({title = "ERROR", text = tostring(awesome.startup_errors)})
end
do
local in_error = false
@ -9,6 +11,7 @@ do
if in_error then return end
in_error = true
loghandler:write("[RUNTIME] "..tostring(err).."\n")
naughty.notify({title = "ERROR", text = tostring(err)})
in_error = false
end)
end

View File

@ -1,5 +0,0 @@
-- Global settings
global = {}
global.terminal = "xfce4-terminal" --Mod+Enter (spawn terminal)
global.browser = "librewolf" --Mod+Shift+Enter (spawn browser)
global.modkey = "Mod4" -- Default modifier key

8
modules/menu_test.lua Normal file
View File

@ -0,0 +1,8 @@
local menu = require("widgets.dismal")({})
local gears = require("gears")
local awful = require("awful")
root.buttons(gears.table.join(
awful.button({}, 3, function() end),
awful.button({}, 4, awful.tag.viewnext),
awful.button({}, 5, awful.tag.viewprev)
))

View File

@ -1,16 +0,0 @@
local awful = require("awful")
local gears = require("gears")
-- Wallpaper applied from homedir
awful.screen.connect_for_each_screen(function(s)
gears.wallpaper.maximized(root_path.."/background.jpg")
end)
awful.rules.rules[1].properties.border_width = 2
awful.rules.rules[1].properties.border_color = "#787B80"
client.connect_signal("focus", function(c)
c.border_color = "#3584E4"
end)
client.connect_signal("unfocus", function(c)
c.border_color = "#787B80"
end)

100
modules/xdg_data.lua Normal file
View File

@ -0,0 +1,100 @@
-- Asynchronous XDG data aggregator
local menu_utils = require("menubar.utils")
local menu_gen = require("menubar.menu_gen")
local awful = require("awful")
local gears = require("gears")
menu_utils.wm_name = ""
-- Directories to scan for .desktop files
local desktop_dirs = {}
local desktop_dirs_complete = 0
local icon_dirs = {}
(os.getenv("XDG_DATA_DIRS")..":/home/yessiest/.local/share"):gsub("[^:]*",function(path)
if gears.filesystem.dir_readable(path.."/applications") then
table.insert(desktop_dirs, path.."/applications")
end
if gears.filesystem.dir_readable(path.."/icons") then
table.insert(icon_dirs, path.."/icons")
end
end)
-- Global xdg data cache
xdg = {
apps = {},
categories = {
Other = {
icon = "applications-other",
apps = {}
},
Wine = {
icon = "wine",
apps = {}
}
}
}
for k,v in pairs(menu_gen.all_categories) do
xdg.categories[v.app_type] = {
name = v.name,
icon = v.icon_name,
apps = {}
}
end
-- Asynchronous scanning process
for k,v in pairs(desktop_dirs) do
awful.spawn.with_line_callback("find "..tostring(v).." -name *.desktop",{
stdout = function(line)
local data = menu_utils.parse_desktop_file(line)
if data.NoDisplay then
return
end
local appdata = {
name = data.Name,
category = "Other",
exec = data.Exec,
icon = (data.Icon and menu_utils.lookup_icon(data.Icon)),
description = data.Comment
}
-- Match first available cateogry for sorting
for k,v in pairs(data.Categories or {"Other"}) do
if xdg.categories[v] then
appdata.category = v
break
end
-- Oh how do I love those Wine applications and their categories
if v:match("^Wine") then
appdata.category = "Wine"
break
end
end
-- Open terminal apps in the terminal (duh)
if data.Terminal then
appdata.exec = global.terminal.." -e "..appdata.exec
end
-- Just for you, Wine - special case because you're being a shit
if (exec and exec:find("%W?wine ")) then
appdata.category = "Wine"
end
table.insert(xdg.apps,appdata)
table.insert(xdg.categories[appdata.category].apps,appdata)
end,
output_done = function()
-- Call a global signal
awesome.emit_signal("xdg::dir_finished",v)
desktop_dirs_complete = desktop_dirs_complete + 1
end
})
end
awesome.connect_signal("xdg::dir_finished",function(dir)
if desktop_dirs_complete == #desktop_dirs then
awesome.emit_signal("xdg::all_finished")
-- Clean up empty categories
for k,v in pairs(xdg.categories) do
if #v.apps == 0 then
xdg.categories[k] = nil
end
end
end
end)

5
rc.lua
View File

@ -9,7 +9,8 @@ package.cpath = package.cpath
-- Modules list
require("modules.errorlog")
require("modules.base")
require("modules.global")
require("modules.binds")
require("modules.temp_crutches")
require("modules.xdg_data")
require("modules.autostart")
require("modules.static_tags")
require("modules.menu_test")

3
themes/default/README Normal file
View File

@ -0,0 +1,3 @@
Background images:
Mikael Eriksson <mikael_eriksson@miffe.org>
Licensed under CC-BY-SA-3.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
themes/default/submenu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

131
themes/default/theme.lua Normal file
View File

@ -0,0 +1,131 @@
---------------------------
-- Default awesome theme --
---------------------------
local theme_assets = require("beautiful.theme_assets")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
local gfs = require("gears.filesystem")
local themes_path = gfs.get_themes_dir()
local theme = {}
theme.font = "sans 8"
theme.bg_normal = "#222222"
theme.bg_focus = "#535d6c"
theme.bg_urgent = "#ff0000"
theme.bg_minimize = "#444444"
theme.bg_systray = theme.bg_normal
theme.fg_normal = "#aaaaaa"
theme.fg_focus = "#ffffff"
theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ffffff"
theme.useless_gap = dpi(0)
theme.border_width = dpi(1)
theme.border_normal = "#000000"
theme.border_focus = "#535d6c"
theme.border_marked = "#91231c"
-- There are other variable sets
-- overriding the default one when
-- defined, the sets are:
-- taglist_[bg|fg]_[focus|urgent|occupied|empty|volatile]
-- tasklist_[bg|fg]_[focus|urgent]
-- titlebar_[bg|fg]_[normal|focus]
-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color]
-- mouse_finder_[color|timeout|animate_timeout|radius|factor]
-- prompt_[fg|bg|fg_cursor|bg_cursor|font]
-- hotkeys_[bg|fg|border_width|border_color|shape|opacity|modifiers_fg|label_bg|label_fg|group_margin|font|description_font]
-- Example:
--theme.taglist_bg_focus = "#ff0000"
-- Generate taglist squares:
local taglist_square_size = dpi(4)
theme.taglist_squares_sel = theme_assets.taglist_squares_sel(
taglist_square_size, theme.fg_normal
)
theme.taglist_squares_unsel = theme_assets.taglist_squares_unsel(
taglist_square_size, theme.fg_normal
)
-- Variables set for theming notifications:
-- notification_font
-- notification_[bg|fg]
-- notification_[width|height|margin]
-- notification_[border_color|border_width|shape|opacity]
-- Variables set for theming the menu:
-- menu_[bg|fg]_[normal|focus]
-- menu_[border_color|border_width]
theme.menu_submenu_icon = themes_path.."default/submenu.png"
theme.menu_height = dpi(15)
theme.menu_width = dpi(100)
-- You can add as many variables as
-- you wish and access them by using
-- beautiful.variable in your rc.lua
--theme.bg_widget = "#cc0000"
-- Define the image to load
theme.titlebar_close_button_normal = themes_path.."default/titlebar/close_normal.png"
theme.titlebar_close_button_focus = themes_path.."default/titlebar/close_focus.png"
theme.titlebar_minimize_button_normal = themes_path.."default/titlebar/minimize_normal.png"
theme.titlebar_minimize_button_focus = themes_path.."default/titlebar/minimize_focus.png"
theme.titlebar_ontop_button_normal_inactive = themes_path.."default/titlebar/ontop_normal_inactive.png"
theme.titlebar_ontop_button_focus_inactive = themes_path.."default/titlebar/ontop_focus_inactive.png"
theme.titlebar_ontop_button_normal_active = themes_path.."default/titlebar/ontop_normal_active.png"
theme.titlebar_ontop_button_focus_active = themes_path.."default/titlebar/ontop_focus_active.png"
theme.titlebar_sticky_button_normal_inactive = themes_path.."default/titlebar/sticky_normal_inactive.png"
theme.titlebar_sticky_button_focus_inactive = themes_path.."default/titlebar/sticky_focus_inactive.png"
theme.titlebar_sticky_button_normal_active = themes_path.."default/titlebar/sticky_normal_active.png"
theme.titlebar_sticky_button_focus_active = themes_path.."default/titlebar/sticky_focus_active.png"
theme.titlebar_floating_button_normal_inactive = themes_path.."default/titlebar/floating_normal_inactive.png"
theme.titlebar_floating_button_focus_inactive = themes_path.."default/titlebar/floating_focus_inactive.png"
theme.titlebar_floating_button_normal_active = themes_path.."default/titlebar/floating_normal_active.png"
theme.titlebar_floating_button_focus_active = themes_path.."default/titlebar/floating_focus_active.png"
theme.titlebar_maximized_button_normal_inactive = themes_path.."default/titlebar/maximized_normal_inactive.png"
theme.titlebar_maximized_button_focus_inactive = themes_path.."default/titlebar/maximized_focus_inactive.png"
theme.titlebar_maximized_button_normal_active = themes_path.."default/titlebar/maximized_normal_active.png"
theme.titlebar_maximized_button_focus_active = themes_path.."default/titlebar/maximized_focus_active.png"
theme.wallpaper = themes_path.."default/background.png"
-- You can use your own layout icons like this:
theme.layout_fairh = themes_path.."default/layouts/fairhw.png"
theme.layout_fairv = themes_path.."default/layouts/fairvw.png"
theme.layout_floating = themes_path.."default/layouts/floatingw.png"
theme.layout_magnifier = themes_path.."default/layouts/magnifierw.png"
theme.layout_max = themes_path.."default/layouts/maxw.png"
theme.layout_fullscreen = themes_path.."default/layouts/fullscreenw.png"
theme.layout_tilebottom = themes_path.."default/layouts/tilebottomw.png"
theme.layout_tileleft = themes_path.."default/layouts/tileleftw.png"
theme.layout_tile = themes_path.."default/layouts/tilew.png"
theme.layout_tiletop = themes_path.."default/layouts/tiletopw.png"
theme.layout_spiral = themes_path.."default/layouts/spiralw.png"
theme.layout_dwindle = themes_path.."default/layouts/dwindlew.png"
theme.layout_cornernw = themes_path.."default/layouts/cornernww.png"
theme.layout_cornerne = themes_path.."default/layouts/cornernew.png"
theme.layout_cornersw = themes_path.."default/layouts/cornersww.png"
theme.layout_cornerse = themes_path.."default/layouts/cornersew.png"
-- Generate Awesome icon:
theme.awesome_icon = theme_assets.awesome_icon(
theme.menu_height, theme.bg_focus, theme.fg_focus
)
-- Define the icon theme for application icons. If not set then the icons
-- from /usr/share/icons and /usr/share/icons/hicolor will be used.
theme.icon_theme = nil
return theme
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

131
widgets/dismal.lua Normal file
View File

@ -0,0 +1,131 @@
-- Dismal - not your average run prompt
local awmtk2 = require("awmtk2")
local wibox = require("wibox")
local gears = require("gears")
local awful = require("awful")
local xdg_search = function(name,rlimit)
local results = {}
for k,v in pairs(xdg.apps) do
if v.name:lower():find(name,nil,true) then
table.insert(results,v)
end
if rlimit <= #results then
break
end
end
return results
end
return function(args)
local style = awmtk2.create_style("dismal",awmtk2.default,args.style)
local templates = awmtk2.create_template_lib("dismal",awmtk2.templates,args.templates)
local t = awmtk2.build_templates(templates,style)
local launchpad = awful.popup(t.popup({
t.container {
t.textbox({
text = "",
id = "inputbox"
}),
layout = wibox.layout.fixed.vertical,
},
t.container({
id = "resultbox",
layout = wibox.layout.fixed.vertical,
spacing = style.container.spacing
},{
bg = style.container.bg_highlight,
forced_width = style.button.width or 180
}),
t.textbox({
markup = "<b>Enter</b> - Run;\n<b>Ctrl+Enter</b> - run in terminal"
}),
spacing = style.container.spacing,
layout = wibox.layout.fixed.vertical
}))
local button_cache = gears.cache(function(name,exec,description,icon)
-- beacause apparently cache doesn't allow nil values
if icon == "" then icon = nil end
local widget = wibox.widget(t.button(t.article({
icon = icon,
resize = true,
title = name,
description = description,
icon_size = (style.button.height and
(style.button.height-style.container.margins)) or
30-style.container.margins
}),{
forced_height = style.button.height or 30
}))
local exec = exec:gsub("%%%w","")
widget:buttons(
gears.table.join(
awful.button({},1,function()
awful.spawn(exec)
launchpad.visible = false
-- i know it's deprecated, you literally give me no option
awful.keygrabber.stop()
end),
awful.button({"Control"},1,function()
awful.spawn({global.terminal,"-e",exec})
launchpad.visible = false
awful.keygrabber.stop()
end),
awful.button({},3,function()
awful.spawn(exec)
end),
awful.button({"Control"},3,function()
awful.spawn({global.terminal,"-e",exec})
end)
)
)
return widget
end)
local modifiers = {}
local results_list = launchpad.widget:get_children_by_id("resultbox")[1]
local input_field = launchpad.widget:get_children_by_id("inputbox")[1]
root.keys(gears.table.join(
root.keys(),
awful.key({ global.modkey }, "r", function()
launchpad.visible = true
if launchpad.visible then
awful.prompt.run {
prompt = "<b>Run: </b>",
textbox = input_field,
hooks = {
{ { "Control" }, "Return", function(cmd)
awful.spawn({global.terminal, "-e", cmd})
end},
{ { }, "Return", function(cmd)
awful.spawn.with_shell(cmd)
end},
{ {}, 'Escape', function(cmd)
input_field.markup = ""
end},
},
done_callback = function()
launchpad.visible = false
end,
changed_callback = function(command)
local results = xdg_search(command,args.result_limit or 5)
results_list:reset()
for k,v in pairs(results) do
results_list:insert(1,button_cache:get(
v.name,
v.exec,
v.description or "",
v.icon or ""
))
end
end,
completion_callback = function(before,after,ncomp)
return awful.completion.shell(before,after,ncomp,global.shell)
end,
history_path = "/tmp/.dismal_history",
history_max = 50
}
end
end)
))
return launchpad
end