From 7ab7fdbb8183077be3b05c3ebd31c3477a60df33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sun, 15 Jan 2023 18:11:55 +0100 Subject: [PATCH] Seperate taglist tasklist and layoutbox for each screen --- awesome/components/pastel/top-panel.lua | 49 ++++++++++++++++-------- awesome/rc.lua | 2 +- awesome/widgets/layout-box.lua | 51 ++++++++++++++----------- awesome/widgets/task-list.lua | 6 +-- nvim/lua/lsp_config.lua | 4 ++ nvim/lua/plugins.lua | 1 + 6 files changed, 71 insertions(+), 42 deletions(-) diff --git a/awesome/components/pastel/top-panel.lua b/awesome/components/pastel/top-panel.lua index b12438f..e253c92 100644 --- a/awesome/components/pastel/top-panel.lua +++ b/awesome/components/pastel/top-panel.lua @@ -1,4 +1,5 @@ --- ████████╗ ██████╗ ██████╗ ██████╗ █████╗ ███╗ ██╗███████╗██╗ +-- ████████╗ ██████╗ ██████╗ █ +-- █████╗ █████╗ ███╗ ██╗███████╗██╗ -- ╚══██╔══╝██╔═══██╗██╔══██╗ ██╔══██╗██╔══██╗████╗ ██║██╔════╝██║ -- ██║ ██║ ██║██████╔╝ ██████╔╝███████║██╔██╗ ██║█████╗ ██║ -- ██║ ██║ ██║██╔═══╝ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║ @@ -16,6 +17,7 @@ local wibox = require("wibox") local theme = require("theme") local lain = require("lain") local tag_list = require("widgets.tag-list") +local layout_box = require("widgets.layout-box") local battery_widget = require("widgets.battery-widget.battery") local volume_widget = require("widgets.volume-widget.volume") local pl = require("powerline") @@ -23,8 +25,6 @@ local pl = require("powerline") -- import widgets local task_list = require("widgets.task-list") - - -- =================================================================== -- Custom Widgets -- =================================================================== @@ -80,6 +80,21 @@ local cpu_widget = wibox.widget{ local clock = wibox.widget.textclock('%a %b %d, %H:%M:%S', 1) +local tag_lists = {} +local current_tag_list = wibox.widget { + layout = wibox.layout.fixed.horizontal +} + +local layout_boxes = {} +local current_layout_box = wibox.widget { + layout = wibox.layout.fixed.horizontal +} + +local task_lists = {} +local current_task_list = wibox.widget { + layout = wibox.layout.fixed.horizontal +} + -- =================================================================== -- Bar Creation -- =================================================================== @@ -94,11 +109,19 @@ top_panel.create = function(s) bg = theme.bg_normal .. "99" }) + for t in screen do + tag_lists[t] = tag_list.create(t) + layout_boxes[t] = layout_box.create(t) + end + + current_tag_list:add(tag_lists[s]) + current_layout_box:add(layout_boxes[s]) + panel:setup { expand = "none", layout = wibox.layout.align.horizontal, task_list.create(s), - tag_list.create(s), + current_tag_list, { layout = wibox.layout.fixed.horizontal, pl(wibox.widget{}, theme.bg_normal .. "00", theme.top_panel_powerline), @@ -109,7 +132,7 @@ top_panel.create = function(s) pl(cpu_widget, theme.top_panel_powerline, theme.bg_normal), pl(frequency_widget, theme.bg_normal, theme.top_panel_powerline), pl(updates_indicator, theme.top_panel_powerline, theme.bg_normal), - pl(require("widgets.layout-box"), theme.bg_normal, theme.top_panel_powerline), + pl(current_layout_box, theme.bg_normal, theme.top_panel_powerline), pl(clock, theme.top_panel_powerline, theme.top_panel_powerline), } } @@ -119,18 +142,14 @@ top_panel.create = function(s) -- Functionality -- =================================================================== - - -- hide panel when client is fullscreen - local function change_panel_visibility(client) - if client.screen == s then - panel.ontop = not client.fullscreen - end - end + client.connect_signal("focus", function (c, _) + current_tag_list:reset(current_tag_list) + current_tag_list:add(tag_lists[c.screen]) + current_layout_box:reset(current_layout_box) + current_layout_box:add(layout_boxes[c.screen]) + end) -- connect panel visibility function to relevant signals - client.connect_signal("property::fullscreen", change_panel_visibility) - client.connect_signal("focus", change_panel_visibility) - updates_indicator:connect_signal("button::press", function(c, _, _, button) awful.spawn.with_shell('WINIT_X11_SCALE_FACTOR=1 alacritty -e bash -c "yay ; echo \'\nDone, press any key to exit...\' ; read"') end) diff --git a/awesome/rc.lua b/awesome/rc.lua index ae23b18..7d55b13 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -90,6 +90,7 @@ client.connect_signal("manage", function (c) -- Prevent clients from being unreachable after screen count changes. awful.placement.no_offscreen(c) end + gears.timer.delayed_call(function() awful.placement.centered(mouse, {parent=c}) end) end) @@ -106,7 +107,6 @@ client.connect_signal("mouse::enter", function(c) c:emit_signal("request::activate", "mouse_enter", {raise = false}) end) - -- =================================================================== -- Screen Change Functions (ie multi monitor) -- =================================================================== diff --git a/awesome/widgets/layout-box.lua b/awesome/widgets/layout-box.lua index c24e953..cd19777 100644 --- a/awesome/widgets/layout-box.lua +++ b/awesome/widgets/layout-box.lua @@ -20,31 +20,36 @@ local awful = require('awful') -- Create an imagebox widget which will contains an icon indicating which layout we're using. -- We need one layoutbox per screen. -local layout_box = awful.widget.layoutbox(s) -layout_box:buttons( - awful.util.table.join( - awful.button({}, 1, - function() - awful.layout.inc(1) - end - ), - awful.button({}, 3, - function() - awful.layout.inc(-1) - end - ), - awful.button({}, 4, - function() - awful.layout.inc(1) - end - ), - awful.button({}, 5, - function() - awful.layout.inc(-1) - end +local layout_box = {} + +layout_box.create = function(s) + local box = awful.widget.layoutbox(s) + box:buttons( + awful.util.table.join( + awful.button({}, 1, + function() + awful.layout.inc(1) + end + ), + awful.button({}, 3, + function() + awful.layout.inc(-1) + end + ), + awful.button({}, 4, + function() + awful.layout.inc(1) + end + ), + awful.button({}, 5, + function() + awful.layout.inc(-1) + end + ) ) ) -) + return box +end return layout_box diff --git a/awesome/widgets/task-list.lua b/awesome/widgets/task-list.lua index d5099c4..c978a66 100644 --- a/awesome/widgets/task-list.lua +++ b/awesome/widgets/task-list.lua @@ -114,10 +114,10 @@ local function list_update(w, buttons, label, data, objects) else -- truncate when title is too long local text_only = text:match('>(.*)<') - local max_length = 10 + local max_length = math.floor(220 / count) if (text_only:len() > max_length) then text = text:gsub('>(.*)<', '>' .. utf8.char(utf8.codepoint(text_only, 1, max_length)) .. '...<') - tt:set_text(text) + tt:set_text(text_only) tt:add_to_object(tb) else tt:remove_from_object(tb) @@ -195,7 +195,7 @@ local filter = function(c, _) if t.selected then local ctags = c:tags() for _, v in ipairs(ctags) do - if v == t then + if v == t and c.screen == client.focus.screen then return true end end diff --git a/nvim/lua/lsp_config.lua b/nvim/lua/lsp_config.lua index 51ea3a1..de45c5d 100644 --- a/nvim/lua/lsp_config.lua +++ b/nvim/lua/lsp_config.lua @@ -157,6 +157,10 @@ require('lspconfig').cssls.setup { capabilities = capabilities } +require('lspconfig').jdtls.setup { + capabilities = capabilities +} + require'lspconfig'.sumneko_lua.setup { settings = { Lua = { diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index cd93933..51b652f 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,5 +1,6 @@ require('packer').startup(function(use) use 'mbbill/undotree' + use 'nvim-tree/nvim-web-devicons' use 'airblade/vim-rooter' use "rafamadriz/friendly-snippets" use 'ConradIrwin/vim-bracketed-paste'