From 820a48dea07375687ed1a23f6a1b44421d1cbe82 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Wed, 27 Nov 2024 01:35:36 +0100 Subject: [PATCH] chore: build awesome-slot from source I'm working on some new updates on awesome-slot that I want to test here on my config before pushing the commits. --- .gitignore | 1 + Makefile | 21 +++++++ scripts/run.sh | 3 +- src/awesomerc/slots/init.lua | 114 +++++++++++++++++++---------------- 4 files changed, 87 insertions(+), 52 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0fc661 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/lua_modules diff --git a/Makefile b/Makefile index 3e52060..b1107c4 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,24 @@ +# Install the dependencies in the local tree (aka project directory). This is +# useful for development, since we may require a different version of a +# dependency than the one installed in the system. +# awesome-slot is on heavy development, so we need to install the dependencies +# from the local source code. +install: + cd /home/aireone/documents/prog/awesome-slot \ + && luarocks \ + --lua-version 5.4 \ + make \ + --tree /home/aireone/documents/prog/awesomerc/lua_modules + luarocks \ + --lua-version 5.4 \ + install \ + --tree lua_modules \ + --only-deps \ + awesomerc-dev-1.rockspec + +clean: + rm -rf lua_modules + dev: scripts/run.sh start diff --git a/scripts/run.sh b/scripts/run.sh index acf2c20..f7b4a30 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -17,7 +17,8 @@ startXephyr() { runAwesome() { DISPLAY=$display $awesome \ --config $rcfile \ - --search $confdir + --search $confdir \ + --search ./lua_modules/share/lua/5.4 } case $1 in diff --git a/src/awesomerc/slots/init.lua b/src/awesomerc/slots/init.lua index 4d95cbf..956e32b 100644 --- a/src/awesomerc/slots/init.lua +++ b/src/awesomerc/slots/init.lua @@ -16,71 +16,83 @@ local cairo = lgi.cairo local slots = {} -function slots.wallpaper(screen) - local screen_geo = screen.geometry - local source = cairo.ImageSurface(cairo.Format.RGB32, screen_geo.width, screen_geo.height) - local cr = cairo.Context(source) +function slots.wallpaper() + return function(screen) + local screen_geo = screen.geometry + local source = cairo.ImageSurface(cairo.Format.RGB32, screen_geo.width, screen_geo.height) + local cr = cairo.Context(source) - -- Load base image - local image_surface = gsurface.load_uncached(beautiful.wallpaper) - local w, h = gsurface.get_size(image_surface) - cr:scale(screen_geo.width / w, screen_geo.height / h) - cr:set_source_surface(image_surface, 0, 0) - cr:paint() + -- Load base image + local image_surface = gsurface.load_uncached(beautiful.wallpaper) + local w, h = gsurface.get_size(image_surface) + cr:scale(screen_geo.width / w, screen_geo.height / h) + cr:set_source_surface(image_surface, 0, 0) + cr:paint() - -- Add color layer - local color_pattern = gcolor.create_linear_pattern { - from = { 0, 0 }, - to = { screen.width, screen.height }, - stops = { - { 0, "#26323840" }, - }, - } - cr:set_source(color_pattern) - cr:paint() + -- Add color layer + local color_pattern = gcolor.create_linear_pattern { + from = { 0, 0 }, + to = { screen.width, screen.height }, + stops = { + { 0, "#26323840" }, + }, + } + cr:set_source(color_pattern) + cr:paint() - awallpaper { - screen = screen, - widget = { - image = source, - widget = imagebox, - }, - } + awallpaper { + screen = screen, + widget = { + image = source, + widget = imagebox, + }, + } + end end -function slots.create_tags(screen) - local first_tag = atag.add("home", { - screen = screen, - layout = alayout.suit.tile, - icon = beautiful.icon_hometag, - gap = beautiful.gaps_hometag, - }) +function slots.create_tags() + return function(screen) + local first_tag = atag.add("home", { + screen = screen, + layout = alayout.suit.tile, + icon = beautiful.icon_hometag, + gap = beautiful.gaps_hometag, + }) - gtimer.delayed_call(function() - first_tag:view_only() - -- spawn(apps.open_terminal(), { screen = screen, tag = first_tag }) - end) + gtimer.delayed_call(function() + first_tag:view_only() + -- spawn(apps.open_terminal(), { screen = screen, tag = first_tag }) + end) + end end -function slots.build_desktop_decoration(screen) - desktop_bar(screen) +function slots.build_desktop_decoration() + return function(screen) + desktop_bar(screen) + end end -function slots.build_titlebars(client) - titlebar(client) +function slots.build_titlebars() + return function(client) + titlebar(client) + end end -function slots.client_shape(client) - client.shape = nice_shapes.rounded_rect { - tl = beautiful.client_corner_radius_top, - tr = beautiful.client_corner_radius_top, - bl = beautiful.client_corner_radius_bottom, - br = beautiful.client_corner_radius_bottom, - } +function slots.client_shape() + return function(client) + client.shape = nice_shapes.rounded_rect { + tl = beautiful.client_corner_radius_top, + tr = beautiful.client_corner_radius_top, + bl = beautiful.client_corner_radius_bottom, + br = beautiful.client_corner_radius_bottom, + } + end end -function slots.naughty_display(notification) - naughty.layout.box { notification = notification } +function slots.naughty_display() + return function(notification) + naughty.layout.box { notification = notification } + end end return slots