From 688c01afc101a5a2170a42750d2306971aa0815b Mon Sep 17 00:00:00 2001 From: Yessiest Date: Wed, 7 Sep 2022 02:40:51 +0400 Subject: [PATCH] Added widget classification --- libs/awmtk2.lua | 1 + modules/desktop.lua | 4 +-- widgets/base/popuptitle.lua | 3 +- widgets/base/subpanel.lua | 3 +- widgets/base/tagswitcher.lua | 3 +- widgets/battery.lua | 61 +++++++++++++++++++----------------- widgets/clientmenu.lua | 2 +- widgets/dismal.lua | 3 +- widgets/lock/clock.lua | 3 +- widgets/lockscreen.lua | 6 ++-- widgets/notifications.lua | 37 +++++++++++++--------- widgets/rootmenu.lua | 2 +- widgets/soundclown.lua | 3 +- widgets/tasklist.lua | 3 +- 14 files changed, 78 insertions(+), 56 deletions(-) diff --git a/libs/awmtk2.lua b/libs/awmtk2.lua index 30a913c..26fb3e4 100644 --- a/libs/awmtk2.lua +++ b/libs/awmtk2.lua @@ -421,5 +421,6 @@ awmtk.generic.iconified_widget = awmtk.create_style("generic_iconified_widget",a awmtk.generic.status_widget = awmtk.create_style("generic_status_widget",awmtk.default,{}) awmtk.generic.oneline_widget = awmtk.create_style("generic_oneline_widget",awmtk.default,{}) awmtk.generic.composite_widget = awmtk.create_style("generic_composite_widget",awmtk.default,{}) +awmtk.generic.popup = awmtk.create_style("generic_popup",awmtk.default,{}) -- }}} return awmtk diff --git a/modules/desktop.lua b/modules/desktop.lua index f6b1c65..3179401 100644 --- a/modules/desktop.lua +++ b/modules/desktop.lua @@ -48,7 +48,7 @@ end -- }}} do --{{{ Screen local wibar_config = {} -local style = awmtk2.create_style("wibar",awmtk2.default,{}) +local style = awmtk2.create_style("wibar",awmtk2.generic.composite_widget,{}) for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do style[v] = awmtk2.create_delta(v, {}, (beautiful.widgets and beautiful.widgets.wibar) or {}, @@ -94,7 +94,7 @@ end -- }}} do -- {{{ Titlebars local titlebar_config = {} -local style = awmtk2.create_style("titlebar",awmtk2.default,{}) +local style = awmtk2.create_style("titlebar",awmtk2.generic.composite_widget,{}) for k,v in pairs({"titlebar_top","titlebar_left","titlebar_right","titlebar_bottom"}) do -- Create styles for each titlebar style[v] = awmtk2.create_delta(v, {}, diff --git a/widgets/base/popuptitle.lua b/widgets/base/popuptitle.lua index 9f7a3ed..4d57f64 100644 --- a/widgets/base/popuptitle.lua +++ b/widgets/base/popuptitle.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("popuptitle",awmtk2.default,args.style) + local style = awmtk2.create_style("popuptitle", + awmtk2.generic.oneline_widget,args.style) local templates = awmtk2.create_template_lib("popuptitle",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local widget = wibox.widget(t.container(t.article({ diff --git a/widgets/base/subpanel.lua b/widgets/base/subpanel.lua index 1620989..867200d 100644 --- a/widgets/base/subpanel.lua +++ b/widgets/base/subpanel.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("subpanel",awmtk2.default,args.style) + local style = awmtk2.create_style("subpanel", + awmtk2.generic.composite_widget,args.style) local templates = awmtk2.create_template_lib("subpanel",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local widget = wibox.widget(t.container(args.layout)) diff --git a/widgets/base/tagswitcher.lua b/widgets/base/tagswitcher.lua index 197c2df..8d7f104 100644 --- a/widgets/base/tagswitcher.lua +++ b/widgets/base/tagswitcher.lua @@ -13,7 +13,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("taglist",awmtk2.default,args.style) + local style = awmtk2.create_style("taglist", + awmtk2.generic.oneline_widget,args.style) local templates = awmtk2.create_template_lib("taglist",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local widget = wibox.widget(t.container(awful.widget.taglist({ diff --git a/widgets/battery.lua b/widgets/battery.lua index e728b63..254facc 100644 --- a/widgets/battery.lua +++ b/widgets/battery.lua @@ -42,7 +42,7 @@ end return function(args) local style = awmtk2.create_style("battery", - awmtk2.generic.status_widget,args.style) + awmtk2.generic.popup,args.style) local templates = awmtk2.create_template_lib("battery",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) -- set up popup layout @@ -52,34 +52,39 @@ return function(args) }) -- create popup local popup = awful.popup(t.popup(layout)) - -- create battery widget - local battery_widget = wibox.widget(t.button({ - { - image = beautiful["battery-missing-symbolic"], - resize = true, - widget = wibox.widget.imagebox, - id = "virtual_id" - }, - (args.percentage and { - markup = "0%", - id = "percentage_id", - widget = wibox.widget.textbox - }), - layout = wibox.layout.fixed.horizontal, - spacing = style.base.spacing - })) - -- make it possible to press the button and make it toggle the popup - battery_widget:connect_signal("button::press",style.button.onpress) - battery_widget:connect_signal("button::release",style.button.onrelease) - battery_widget:connect_signal("button::press",function(self,x,y,button) - if button == 1 then - popup.visible = (not popup.visible) - if popup.visible then - popup:move_next_to(mouse.current_widget_geometry) + local battery_widget + do -- create battery widget + local style = awmtk2.create_style("battery", + awmtk2.generic.status_widget,args.style) + local templates = awmtk2.create_template_lib("battery",awmtk2.templates,args.templates) + local t = awmtk2.build_templates(templates,style) + battery_widget = wibox.widget(t.button({ + { + image = beautiful["battery-missing-symbolic"], + resize = true, + widget = wibox.widget.imagebox, + id = "virtual_id" + }, + (args.percentage and { + markup = "0%", + id = "percentage_id", + widget = wibox.widget.textbox + }), + layout = wibox.layout.fixed.horizontal, + spacing = style.base.spacing + })) + -- make it possible to press the button and make it toggle the popup + battery_widget:connect_signal("button::press",style.button.onpress) + battery_widget:connect_signal("button::release",style.button.onrelease) + battery_widget:connect_signal("button::press",function(self,x,y,button) + if button == 1 then + popup.visible = (not popup.visible) + if popup.visible then + popup:move_next_to(mouse.current_widget_geometry) + end end - end - end) - + end) + end -- map widgets to their names to make it easier to update separate components local widget_map = {} -- also map current charge state of every device to get the icon for the tray diff --git a/widgets/clientmenu.lua b/widgets/clientmenu.lua index ed920e4..5a3b5e9 100644 --- a/widgets/clientmenu.lua +++ b/widgets/clientmenu.lua @@ -14,7 +14,7 @@ local beautiful = require("beautiful") local menugen = require("context_menu") local builder = require("builder") local style = awmtk2.create_style("client_menu", - awmtk2.generic.menu,{}) + awmtk2.generic.composite_widget,{}) local templates = awmtk2.create_template_lib("client_menu",awmtk2.templates,{}) local t = awmtk2.build_templates(templates,style) diff --git a/widgets/dismal.lua b/widgets/dismal.lua index dcf587e..010be73 100644 --- a/widgets/dismal.lua +++ b/widgets/dismal.lua @@ -27,7 +27,8 @@ local xdg_search = function(name,rlimit) end return function(args) - local style = awmtk2.create_style("dismal",awmtk2.default,args.style) + local style = awmtk2.create_style("dismal", + awmtk2.generic.popup,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({ diff --git a/widgets/lock/clock.lua b/widgets/lock/clock.lua index 81a603f..82df2e9 100644 --- a/widgets/lock/clock.lua +++ b/widgets/lock/clock.lua @@ -16,7 +16,8 @@ local DateTime = glib.DateTime local TimeZone = glib.TimeZone return function(args) - local style = awmtk2.create_style("lock_clock",awmtk2.default,args.style) + local style = awmtk2.create_style("lock_clock", + awmtk2.generic.status_widget,args.style) local templates = awmtk2.create_template_lib("lock_clock",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) -- Don't mind me just stealing default library code diff --git a/widgets/lockscreen.lua b/widgets/lockscreen.lua index 724488e..7fa110b 100644 --- a/widgets/lockscreen.lua +++ b/widgets/lockscreen.lua @@ -31,7 +31,8 @@ local function _preload(args) do -- {{{ Lock bar local config_path = root_path.."/themes/"..global.theme.."/config/lockbar.json" if readable(config_path) then - local style = awmtk2.create_style("lockbar", awmtk2.default, args.style) + local style = awmtk2.create_style("lockbar", + awmtk2.generic.composite_widget, args.style) local templates = awmtk2.create_template_lib("lockbar",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local config_file = io.open(config_path,"r") @@ -50,7 +51,8 @@ local function _preload(args) end end -- }}} do -- {{{ Lock widget - local style = awmtk2.create_style("lockpanel", awmtk2.default, args.style) + local style = awmtk2.create_style("lockpanel", + awmtk2.generic.composite_widget, args.style) local templates = awmtk2.create_template_lib("lockpanel",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local config_path = root_path.."/themes/"..global.theme.."/config/lockpanel.json" diff --git a/widgets/notifications.lua b/widgets/notifications.lua index 9af4f89..ae57e49 100644 --- a/widgets/notifications.lua +++ b/widgets/notifications.lua @@ -16,7 +16,7 @@ local naughty = require("naughty") return function(args) local style = awmtk2.create_style("notifications", - awmtk2.generic.iconified_widget,args.style) + awmtk2.generic.popup,args.style) local templates = awmtk2.create_template_lib("notifications",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local layout = wibox.widget({ @@ -82,20 +82,27 @@ return function(args) return update_args end -- create popup button - local clip_widget = wibox.widget(t.button({ - image = beautiful["notifications-area-symbolic"], - resize = true, - widget = wibox.widget.imagebox, - })) - clip_widget:connect_signal("button::press",style.button.onpress) - clip_widget:connect_signal("button::release",style.button.onrelease) - clip_widget:connect_signal("button::press",function(self,x,y,button) - if button == 1 then - popup.visible = (not popup.visible) - if popup.visible then - popup:move_next_to(mouse.current_widget_geometry) + local clip_widget + do + local style = awmtk2.create_style("notifications", + awmtk2.generic.iconified_widget,args.style) + local templates = awmtk2.create_template_lib("notifications",awmtk2.templates,args.templates) + local t = awmtk2.build_templates(templates,style) + clip_widget = wibox.widget(t.button({ + image = beautiful["notifications-area-symbolic"], + resize = true, + widget = wibox.widget.imagebox, + })) + clip_widget:connect_signal("button::press",style.button.onpress) + clip_widget:connect_signal("button::release",style.button.onrelease) + clip_widget:connect_signal("button::press",function(self,x,y,button) + if button == 1 then + popup.visible = (not popup.visible) + if popup.visible then + popup:move_next_to(mouse.current_widget_geometry) + end end - end - end) + end) + end return clip_widget end diff --git a/widgets/rootmenu.lua b/widgets/rootmenu.lua index 6f89b6f..0ba9328 100644 --- a/widgets/rootmenu.lua +++ b/widgets/rootmenu.lua @@ -15,7 +15,7 @@ local builder = require("builder") return function(args) local style = awmtk2.create_style("root_menu", - awmtk2.generic.menu,{}) + awmtk2.generic.composite_widget,{}) local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{}) local t = awmtk2.build_templates(templates,style) local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r") diff --git a/widgets/soundclown.lua b/widgets/soundclown.lua index b23a2d3..0d8b2a9 100644 --- a/widgets/soundclown.lua +++ b/widgets/soundclown.lua @@ -14,7 +14,8 @@ local awful = require("awful") local beautiful = require("beautiful") return function(args) - local style = awmtk2.create_style("soundclown",awmtk2.default,args.style) + local style = awmtk2.create_style("soundclown", + awmtk2.generic.oneline_widget,args.style) local templates = awmtk2.create_template_lib("soundclown",awmtk2.templates,args.templates) local t = awmtk2.build_templates(templates,style) local test = os.execute("mpc help") diff --git a/widgets/tasklist.lua b/widgets/tasklist.lua index 88d1000..2987410 100644 --- a/widgets/tasklist.lua +++ b/widgets/tasklist.lua @@ -31,7 +31,8 @@ local tasklist_buttons = gears.table.join( ) return function(args) - local style = awmtk2.create_style("tasklist", awmtk2.default, args.style) + local style = awmtk2.create_style("tasklist", + awmtk2.generic.oneline_widget, args.style) local templates = awmtk2.create_template_lib("tasklist", awmtk2.templates, args.templates) local t = awmtk2.build_templates(templates,style) local button = t.button({