From 76b7c0375618ae4fe408b06bdc6051ea50eb10e9 Mon Sep 17 00:00:00 2001 From: actionless Date: Thu, 19 Dec 2024 21:13:44 +0100 Subject: [PATCH] feat(widgets, config): implement new screen_layouts widget based on new `script_switcher` base and add it to the sidebar in the config --- actionless/widgets/init.lua | 1 + actionless/widgets/screen_layouts.lua | 55 +++++++++++++++++++++++++++ config/widgets.lua | 1 + 3 files changed, 57 insertions(+) create mode 100644 actionless/widgets/screen_layouts.lua diff --git a/actionless/widgets/init.lua b/actionless/widgets/init.lua index 141db069..9fb02068 100644 --- a/actionless/widgets/init.lua +++ b/actionless/widgets/init.lua @@ -18,6 +18,7 @@ local widgets = { backlight = require("actionless.widgets.backlight"), script_switcher = require("actionless.widgets.script_switcher"), pipewire_helper = require("actionless.widgets.pipewire_helper"), + screen_layouts = require("actionless.widgets.screen_layouts"), } return widgets diff --git a/actionless/widgets/screen_layouts.lua b/actionless/widgets/screen_layouts.lua new file mode 100644 index 00000000..1d380744 --- /dev/null +++ b/actionless/widgets/screen_layouts.lua @@ -0,0 +1,55 @@ +--[[ + Licensed under GNU General Public License v2 + * (c) 2024, Yauheni Kirylau +--]] + +--local awful = require("awful") + +local script_switcher = require("actionless.widgets.script_switcher") +--local get_icon = require("actionless.util.xdg").get_icon + + +-- screen_layouts infos +local screen_layouts = { +} + + +function screen_layouts.init(widget_args) + local home = os.getenv("HOME") + widget_args = widget_args or {} + widget_args.name = widget_args.name or "screen_layouts" + widget_args.scripts = widget_args.scripts or { + { + cmd=home.."/.screenlayout/main_only.sh", + cmd_off="true", + title="Main Screen Only", + }, + { + cmd=home.."/.screenlayout/two_screens_bottom_right.sh", + cmd_off="true", + title="2 screens: Main -> TouchScreen", + }, + } + widget_args.extra_funcs = widget_args.extra_funcs or { + --{ + -- "restuck", + -- function() + -- awful.spawn.with_shell( + -- "pw-metadata -n settings 0 clock.force-quantum 256" + -- .." ; pw-metadata -n settings 0 clock.force-quantum 1024" + -- ) + -- end, + -- get_icon('actions', 'view-refresh') + --}, + } + screen_layouts = script_switcher.init(widget_args) + return setmetatable(screen_layouts, { __index = screen_layouts.widget }) +end + +return setmetatable( + screen_layouts, + { __call = function(_, ...) + return screen_layouts.init(...) + end + } +) diff --git a/config/widgets.lua b/config/widgets.lua index f9d238f9..7a82c321 100644 --- a/config/widgets.lua +++ b/config/widgets.lua @@ -77,6 +77,7 @@ function widget_loader.init(awesome_context) end w.pipewire_helper = widgets.pipewire_helper({}) + w.screen_layouts = widgets.screen_layouts({}) -- MEM w.mem = widgets.mem({