From 4003e4a681c7f269032216e1103bed94c93f4d67 Mon Sep 17 00:00:00 2001 From: willecg Date: Sat, 13 May 2023 16:17:22 -0600 Subject: [PATCH] Minimal corrections and progressbar usage --- rc.lua | 7 +- themes/crystal/theme.lua | 215 ++++++++++++++++++++++----------------- 2 files changed, 124 insertions(+), 98 deletions(-) diff --git a/rc.lua b/rc.lua index a736cbd..8083984 100644 --- a/rc.lua +++ b/rc.lua @@ -20,9 +20,11 @@ require("awful.hotkeys_popup.keys") local dpi = require("beautiful.xresources").apply_dpi local freedesktop = require("freedesktop") +os.setlocale(os.getenv("LANG")) local conf = require("conf") + -- {{{ Error handling -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) @@ -58,7 +60,7 @@ terminal = "alacritty" editor = os.getenv("EDITOR") or "emacs" editor_cmd = editor -awful.util.tagnames = {"➀", "➁", "➂", "➃", "➄", "➅", "➆", "➇", "➈"} +awful.util.tagnames = {"1", "2", "3", "4", "5", "6", "7", "8", "9"} -- Default modkey. -- Usually, Mod4 is the key with a logo between Control and Alt. -- If you do not like this or do not have such a key, @@ -104,7 +106,8 @@ awful.util.mymainmenu = freedesktop.menu.build { }, after = { { "Open terminal", terminal }, - -- other triads can be put here + { "Emacs Client", "emacsclient -c -a emacs"}, + { "GNU Emacs", "emacs"} } } diff --git a/themes/crystal/theme.lua b/themes/crystal/theme.lua index 758219b..e702c2e 100644 --- a/themes/crystal/theme.lua +++ b/themes/crystal/theme.lua @@ -35,10 +35,10 @@ end -theme.font = "Cantarell Bold 9" +theme.font = "Sans 8" theme.windows_shape = function(cr, w, h) - gears.shape.rounded_rect(cr, w, h, 7) + gears.shape.rounded_rect(cr, w, h, 5) end @@ -57,7 +57,7 @@ theme.bg_normal = theme.black .. "50" theme.bg_focus = theme.black .. "50" theme.bg_urgent = theme.red theme.bg_minimize = theme.bg_normal -theme.bg_systray = theme.black +theme.bg_systray = theme.blue .. "20" theme.fg_normal = theme.white theme.fg_focus = theme.white @@ -76,6 +76,8 @@ theme.taglist_bg_empty = theme.bg_normal .. "00" theme.taglist_bg_occupied = theme.bg_normal .. "00" theme.tasklist_bg_focus = theme.bg_focus theme.tasklist_fg_focus = theme.fg_focus +theme.tasklist_bg_normal = theme.bg_normal .. "00" +theme.tasklist_fg_normal = theme.fg_normal theme.hotkeys_bg = theme.white theme.hotkeys_modifiers_fg = theme.black @@ -83,9 +85,9 @@ theme.hotkeys_label_fg = theme.black theme.hotkeys_fg = theme.black theme.taglist_squares_sel = theme_path .. "squares_sel.svg" - + theme.taglist_squares_unsel = theme_path .. "squares_unsel.svg" - + theme.notification_font = "Cantarell 9" theme.notification_bg = theme.bg_normal @@ -197,15 +199,7 @@ theme.layout_centerworkh = icon_theme_path.."layouts/centerworkh.svg" local mylauncher = awful.widget.button({image = theme.awesome_icon}) mylauncher:connect_signal("button::press", function() awful.util.mymainmenu:toggle() end) -lch_background = wibox.widget { - { - mylauncher, - widget = wibox.container.background - }, - layout = wibox.layout.fixed.horizontal -} - -mytextclock = wibox.widget.textclock(" %d/%m/%Y %I:%M ") +mytextclock = wibox.widget.textclock("%A, %d de %B del %Y. %H:%M:%S", 1) tc_background = wibox.widget { { @@ -231,7 +225,7 @@ local calendario = lain.widget.cal({ st_background = wibox.widget { { wibox.widget.systray(), - margin = 4, + --margin = 4, widget = wibox.container.background }, layout = wibox.layout.fixed.horizontal @@ -353,38 +347,74 @@ local org_background = wibox.widget { -- cpu widget local i_cpu = wibox.widget.imagebox(theme.cpu) +local progress_cpu = wibox.widget{ + max_value = 100, + value = 0, + forced_width = 50, + paddings = 1, + border_width = 1, + border_color = theme.fg_normal, + background_color = theme.bg_normal .. "00", + color = theme.blue, + bar_shape = gears.shape.rounded_rect, + shape = gears.shape.rounded_rect, + widget = wibox.widget.progressbar +} local cpu = lain.widget.cpu { settings = function() i_cpu:set_image(theme.cpu) if cpu_now.usage >=80 then - widget:set_markup('' ..cpu_now.usage .. '% ') + widget:set_markup(' ' ..cpu_now.usage .. '% ') else - widget:set_markup(cpu_now.usage .. '% ') + widget:set_markup(' ' .. cpu_now.usage .. '% ') end + progress_cpu.value = cpu_now.usage end } cpu_background = wibox.widget { i_cpu, - cpu.widget, + wibox.widget{ + progress_cpu, + cpu.widget, + layout = wibox.layout.stack + }, layout = wibox.layout.fixed.horizontal, forced_height = 24 } -- mem widget local i_ram = wibox.widget.imagebox(theme.ram) +local progress_ram = wibox.widget{ + max_value = 100, + value = 0, + forced_width = 50, + paddings = 1, + border_width = 1, + border_color = theme.fg_normal, + background_color = theme.bg_normal .. "00", + color = theme.blue, + bar_shape = gears.shape.rounded_rect, + shape = gears.shape.rounded_rect, + widget = wibox.widget.progressbar +} local ram = lain.widget.mem { settings = function() i_ram:set_image(theme.ram) + progress_ram.value = mem_now.perc if mem_now.perc >= 80 then - widget:set_markup(' ' .. mem_now.perc .. '%') + widget:set_markup(' ' .. mem_now.perc .. '%') else - widget:set_markup(mem_now.perc .. '%') + widget:set_markup(' ' .. mem_now.perc .. '%') end end } ram_background = wibox.widget { i_ram, - ram.widget, + wibox.widget{ + progress_ram, + ram.widget, + layout = wibox.layout.stack + }, layout = wibox.layout.fixed.horizontal, forced_height = 24 } @@ -454,7 +484,7 @@ local vol = awful.widget.watch( end local mute = string.match(stdout, "Mute: (%S+)") or "N/A" - + if mute == "N/A" or mute == "sí" then i_vol:set_image(theme.vol_mute) elseif volume <= 10 then @@ -468,7 +498,7 @@ local vol = awful.widget.watch( end widget:set_markup(voloutput) - end + end ) theme.vol_background = wibox.widget { @@ -488,9 +518,9 @@ bat = lain.widget.bat({ if bat_now.status == "Charging" then widget:set_markup(tonumber(bat_now.perc) .. "%") if tonumber(bat_now.perc) <= 15 then - i_bat:set_image(theme.bat_empty_con) + i_bat:set_image(theme.bat_empty_con) elseif tonumber(bat_now.perc) <= 50 then - i_bat:set_image(theme.bat_low_con) + i_bat:set_image(theme.bat_low_con) elseif tonumber(bat_now.perc) <= 85 then i_bat:set_image(theme.bat_mid_con) else @@ -511,7 +541,7 @@ bat = lain.widget.bat({ widget:set_markup(" Cargado ") i_bat:set_image(theme.bat_full) end -end + end }) bat_background = wibox.widget { @@ -563,73 +593,65 @@ function theme.screen_connect(s) } } - ltg_background = wibox.widget { - { - s.mytaglist, - widget = wibox.container.background + s.mytasklist = awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = awful.util.tasklist_buttons, + style = { + shape_border_width = 1, + shape_border_color = theme.border_normal, + shape = gears.shape.rounded_rect, }, - layout = wibox.layout.fixed.horizontal - } - - s.mytasklist = awful.widget.tasklist { - screen = s, - filter = awful.widget.tasklist.filter.currenttags, - buttons = awful.util.tasklist_buttons, - style = { - shape_border_width = 1, - shape_border_color = theme.border_normal, - shape = gears.shape.rounded_rect, - }, - layout = { - spacing = 10, - spacing_widget = { - { - forced_width = 5, - shape = gears.shape.circle, - widget = wibox.widget.separator - }, - valign = 'center', - halign = 'center', - widget = wibox.container.place, + layout = { + spacing = 10, + spacing_widget = { + { + forced_width = 2, + shape = gears.shape.circle, + widget = wibox.widget.separator }, - layout = wibox.layout.flex.horizontal + valign = 'center', + halign = 'center', + widget = wibox.container.place, }, - -- Notice that there is *NO* wibox.wibox prefix, it is a template, - -- not a widget instance. - widget_template = { + layout = wibox.layout.flex.horizontal + }, + -- Notice that there is *NO* wibox.wibox prefix, it is a template, + -- not a widget instance. + widget_template = { + { { { { - { - id = 'icon_role', - widget = wibox.widget.imagebox, - }, - margins = 2, - widget = wibox.container.margin, + id = 'icon_role', + widget = wibox.widget.imagebox, }, - { - id = 'text_role', - widget = wibox.widget.textbox, - }, - layout = wibox.layout.fixed.horizontal, + margins = 2, + widget = wibox.container.margin, }, - left = 10, - right = 10, - widget = wibox.container.margin + { + id = 'text_role', + widget = wibox.widget.textbox, + }, + layout = wibox.layout.fixed.horizontal, }, - id = 'background_role', - widget = wibox.container.background, + left = 10, + right = 10, + widget = wibox.container.margin }, + id = 'background_role', + widget = wibox.container.background, + }, - } - ltsk_background = wibox.widget { - { - s.mytasklist, - bg = theme.bg_normal, - widget = wibox.container.background - }, - layout = wibox.layout.align.horizontal - } + } + ltsk_background = wibox.widget { + { + s.mytasklist, + bg = theme.bg_normal, + widget = wibox.container.background + }, + layout = wibox.layout.align.horizontal + } -- Create the wibox @@ -639,21 +661,22 @@ function theme.screen_connect(s) s_width = s.workarea.width - (theme.useless_gap + theme.border_width) * 4 s.mwibox = awful.wibar({ position = "top", screen = s, height = theme.wibar_height, - width = s_width, shape = wibox_shape}) + width = s_width, shape = wibox_shape}) -- Add widgets to the wibox - local h_margin = 2 - local v_margin = 7 + local h_margin = 4 + local v_margin = 4 -- -- Add widgets to the wibox s.mwibox:setup { layout = wibox.layout.align.horizontal, { -- Left widgets layout = wibox.layout.fixed.horizontal, - wibox.container.margin(lch_background, h_margin + 4, h_margin, v_margin, v_margin), - wibox.container.margin(ltg_background, h_margin, h_margin, 1, 1), + wibox.container.margin(mylauncher, h_margin + 4, h_margin, v_margin, v_margin), + + s.mytaglist, s.mypromptbox, }, - wibox.container.margin(s.mytasklist, 2, 2, 2, 2), -- Middle widget + s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, spacing = 4, @@ -666,7 +689,7 @@ function theme.screen_connect(s) wibox.container.margin(net_background, h_margin, h_margin, v_margin, v_margin), wibox.container.margin(theme.vol_background, h_margin, h_margin, v_margin, v_margin), wibox.container.margin(bat_background, h_margin, h_margin, v_margin, v_margin), - st_background, + wibox.container.margin(wibox.widget.systray(), h_margin, h_margin, v_margin, v_margin), wibox.container.margin(mytextclock, h_margin, h_margin, v_margin, v_margin), wibox.container.margin(s.mylayoutbox, h_margin, h_margin + 4, v_margin, v_margin), }, @@ -687,10 +710,10 @@ function theme.set_title_bar(c) awful.titlebar(c, {size = 16}) : setup { { -- Left - wibox.container.margin(awful.titlebar.widget.iconwidget(c), 4, 4, 4, 4), - wibox.container.margin(awful.titlebar.widget.floatingbutton (c), 4, 4, 4, 4), - wibox.container.margin(awful.titlebar.widget.ontopbutton (c), 4, 4, 4, 4), - wibox.container.margin(awful.titlebar.widget.stickybutton (c), 4, 4, 4, 4), + wibox.container.margin(awful.titlebar.widget.iconwidget(c), h_margin, h_margin, v_margin, v_margin), + wibox.container.margin(awful.titlebar.widget.floatingbutton (c), h_margin, h_margin, v_margin, v_margin), + wibox.container.margin(awful.titlebar.widget.ontopbutton (c), h_margin, h_margin, v_margin, v_margin), + wibox.container.margin(awful.titlebar.widget.stickybutton (c), h_margin, h_margin, v_margin, v_margin), layout = wibox.layout.fixed.horizontal }, @@ -703,9 +726,9 @@ function theme.set_title_bar(c) layout = wibox.layout.flex.horizontal }, { -- Right - wibox.container.margin(awful.titlebar.widget.minimizebutton(c), 4, 4, 4, 4), - wibox.container.margin(awful.titlebar.widget.maximizedbutton(c), 4, 4, 4, 4), - wibox.container.margin(awful.titlebar.widget.closebutton (c), 4, 4, 4, 4), + wibox.container.margin(awful.titlebar.widget.minimizebutton(c), h_margin, h_margin, v_margin, v_margin), + wibox.container.margin(awful.titlebar.widget.maximizedbutton(c), h_margin, h_margin, v_margin, v_margin), + wibox.container.margin(awful.titlebar.widget.closebutton (c), h_margin, h_margin, v_margin, v_margin), layout = wibox.layout.fixed.horizontal() }, layout = wibox.layout.align.horizontal