From 33b6b84815bc04634125c332d2e3bb8dd1be2265 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Av=C3=A9?= <email@thomasave.be>
Date: Wed, 27 Jul 2022 01:43:14 +0200
Subject: [PATCH] Add custom Taglist

---
 awesome/components/pastel/top-panel.lua |  3 +-
 awesome/keys.lua                        |  4 +-
 awesome/pastel.lua                      |  8 ++-
 awesome/rc.lua                          | 23 +--------
 awesome/theme.lua                       |  9 ++--
 awesome/widgets/tag-list.lua            | 67 +++++++++++++++++++++++++
 nvim/lua/lsp_config.lua                 |  5 +-
 rofi/config.rasi                        |  2 +-
 8 files changed, 84 insertions(+), 37 deletions(-)
 create mode 100644 awesome/widgets/tag-list.lua

diff --git a/awesome/components/pastel/top-panel.lua b/awesome/components/pastel/top-panel.lua
index cc03f55..2e4b947 100644
--- a/awesome/components/pastel/top-panel.lua
+++ b/awesome/components/pastel/top-panel.lua
@@ -15,6 +15,7 @@ local beautiful = require("beautiful")
 local wibox = require("wibox")
 local theme = require("theme")
 local lain = require("lain")
+local tag_list = require("widgets.tag-list")
 local battery_widget = require("widgets.battery-widget.battery")
 local volume_widget = require("widgets.volume-widget.volume")
 local pl = require("powerline")
@@ -95,7 +96,7 @@ top_panel.create = function(s)
         expand = "none",
         layout = wibox.layout.align.horizontal,
         task_list.create(s),
-        nil,
+        tag_list.create(s),
         {
             layout = wibox.layout.fixed.horizontal,
             pl(wibox.widget{}, theme.bg_normal .. "00", theme.top_panel_powerline),
diff --git a/awesome/keys.lua b/awesome/keys.lua
index 35d06cf..0474d35 100644
--- a/awesome/keys.lua
+++ b/awesome/keys.lua
@@ -18,7 +18,7 @@ local beautiful = require("beautiful")
 local volume_widget = require("widgets.volume-widget.volume")
 local dpi = beautiful.xresources.apply_dpi
 
--- Define mod keys
+
 local modkey = "Mod4"
 local altkey = "Shift"
 
@@ -162,7 +162,7 @@ keys.globalkeys = gears.table.join(
         {description = "Open Nautilus", group = "launcher"}
     ),
     -- launch rofi
-    awful.key({modkey}, "d",
+    awful.key({modkey, altkey}, "F9",
         function()
             awful.spawn("/home/user/.config/awesome/scripts/toggle_rofi.sh")
         end,
diff --git a/awesome/pastel.lua b/awesome/pastel.lua
index c051c2d..b969184 100644
--- a/awesome/pastel.lua
+++ b/awesome/pastel.lua
@@ -11,9 +11,8 @@
 
 
 local awful = require("awful")
-local gears = require("gears")
 local lain = require("lain")
-local quake = lain.util.quake({app="kitty", followtag=true, argname = '--class %s', extra="-e tmux", height=0.3})
+local quake = lain.util.quake({app="alacritty", followtag=true, argname = '--class %s', extra="--option=window.opacity=1.0 --option=\"colors.primary.background='#000d2b'\" -e tmux", height=0.3})
 
 local pastel = {}
 
@@ -35,8 +34,7 @@ pastel.initialize = function()
     awful.screen.connect_for_each_screen(function(s)
         for i = 1, 9, 1
         do
-            awful.tag.add(i, {
-                icon_only = true,
+            awful.tag.add(tostring(i), {
                 layout = awful.layout.suit.tile,
                 screen = s,
                 selected = i == 1
@@ -47,7 +45,7 @@ pastel.initialize = function()
 
         -- Only add the top panel on the primary screen
         if s.index == 1 then
-             top_panel.create(s)
+            top_panel.create(s)
         end
 
     end)
diff --git a/awesome/rc.lua b/awesome/rc.lua
index 7576fb2..a86fe42 100644
--- a/awesome/rc.lua
+++ b/awesome/rc.lua
@@ -16,8 +16,6 @@ local awful = require("awful")
 -- ===================================================================
 
 
-local theme_config_dir = gears.filesystem.get_configuration_dir() .. "/configuration/"
-
 -- define default apps (global variable so other components can access it)
 apps = {
     network_manager = "nm-connection-editor", -- recommended: nm-connection-editor
@@ -29,18 +27,11 @@ apps = {
     filebrowser = "nautilus"
 }
 
--- define wireless and ethernet interface names for the network widget
--- use `ip link` command to determine these
-network_interfaces = {
-    lan = 'enp4s0'
-}
-
 -- List of apps to run on start-up
 local run_on_start_up = {
      "numlockx on",
-     "bluetoothctl power on",
      "nm-applet",
-     "xcape -e \"Super_L=Super_L|d\""
+     "xcape -e \"Super_L=Super_L|Shift_L|F9\""
 }
 
 -- ===================================================================
@@ -90,16 +81,6 @@ awful.layout.layouts = {
      awful.layout.suit.fair.horizontal,
 }
 
--- remove gaps if layout is set to max
-tag.connect_signal('property::layout', function(t)
-    local current_layout = awful.tag.getproperty(t, 'layout')
-    if (current_layout == awful.layout.suit.max) then
-        t.gap = 0
-    else
-        t.gap = beautiful.useless_gap
-    end
-end)
-
 -- Signal function to execute when a new client appears.
 client.connect_signal("manage", function (c)
     -- Set the window as a slave (put it at the end of others instead of setting it as master)
@@ -152,7 +133,7 @@ require("awesomewm-vim-tmux-navigator") {
      right = {"Right", "l"},
      mod = "Mod4",
      mod_keysym = "Super_L",
-     -- experimental = true
+     experimental = true
 }
 
 local handle_single_win = function(focused)
diff --git a/awesome/theme.lua b/awesome/theme.lua
index eddf645..61d7214 100644
--- a/awesome/theme.lua
+++ b/awesome/theme.lua
@@ -53,12 +53,6 @@ theme.border_normal = theme.bg_normal
 theme.border_focus = "#ff0000"
 theme.border_marked = theme.fg_urgent
 
--- Taglist
-theme.taglist_bg_empty = theme.bg_normal
-theme.taglist_bg_occupied = "#ffffff1a"
-theme.taglist_bg_urgent = "#e91e6399"
-theme.taglist_bg_focus = theme.bg_focus
-
 -- Tasklist
 theme.tasklist_font = theme.font
 
@@ -74,6 +68,9 @@ theme.tasklist_fg_normal = theme.fg_normal
 theme.top_panel_height = dpi(30)
 theme.top_panel_powerline = "#002F5F"
 
+-- Taglist
+theme.taglist_bg_focus = theme.top_panel_powerline
+
 -- Notification Sizing
 theme.notification_max_width = dpi(350)
 
diff --git a/awesome/widgets/tag-list.lua b/awesome/widgets/tag-list.lua
new file mode 100644
index 0000000..4387a52
--- /dev/null
+++ b/awesome/widgets/tag-list.lua
@@ -0,0 +1,67 @@
+local awful = require("awful")
+local gears = require("gears")
+local wibox = require("wibox")
+local theme = require("theme")
+local naughty = require("naughty")
+
+local tag_list = {}
+
+tag_list.create = function(s)
+    local filter = function(tag)
+        count = 0
+        for idx, tag in ipairs(s.tags) do
+            if #tag:clients() > 0 or tag.selected then
+                count = count + 1
+            end
+        end
+        return (#tag:clients() > 0 and count > 1) or (tag.selected and #tag:clients() == 0)
+    end
+
+    local taglist_buttons = awful.util.table.join(
+        awful.button({}, 1,
+        function(c)
+            c.selected = true
+            for idx, tag in ipairs(s.tags) do
+                if tag.index ~= c.index then
+                    tag.selected = false
+                end
+            end
+        end
+        )
+    )
+    return awful.widget.taglist {
+        screen  = s,
+        -- filter  = awful.widget.taglist.filter.noempty,
+        filter  = filter,
+        widget_template = {
+            {
+                {
+                    id     = 'index_role',
+                    widget = wibox.widget.textbox,
+                },
+                left  = 10,
+                right = 10,
+                widget = wibox.container.margin
+            },
+            id     = 'background_role',
+            widget = wibox.container.background,
+
+            create_callback = function(self, c3, index, objects)
+                self:get_children_by_id('index_role')[1].markup = '<b> '..c3.name..' </b>'
+                self:connect_signal('mouse::enter', function()
+                    if self.bg ~= theme.top_panel_powerline then
+                        self.backup     = self.bg
+                        self.has_backup = true
+                    end
+                    self.bg = theme.top_panel_powerline
+                end)
+                self:connect_signal('mouse::leave', function()
+                    if self.has_backup and not c3.selected then self.bg = self.backup end
+                end)
+            end,
+        },
+        buttons = taglist_buttons,
+    }
+
+end
+return tag_list
diff --git a/nvim/lua/lsp_config.lua b/nvim/lua/lsp_config.lua
index 8f9dfb9..9922f62 100644
--- a/nvim/lua/lsp_config.lua
+++ b/nvim/lua/lsp_config.lua
@@ -104,7 +104,10 @@ require('lspconfig').texlab.setup {
 }
 
 require('lspconfig').clangd.setup {
-    capabilities = capabilities
+    capabilities = capabilities,
+    -- root_dir = function()
+    --     return require('lspconfig').util.root_pattern({'.clang-format', 'build/', 'compile_flags.txt'})
+    -- end
 }
 
 require('lspconfig').bashls.setup {
diff --git a/rofi/config.rasi b/rofi/config.rasi
index 5d171fc..2e67580 100644
--- a/rofi/config.rasi
+++ b/rofi/config.rasi
@@ -2,7 +2,7 @@ configuration {
   font: "SF Pro Rounded 13";
   show-icons: true;
   icon-theme: "Papirus";
-  kb-cancel: "Super_L+d,Escape";
+  kb-cancel: "Super_L+Shift_L+F9,Escape";
   combi-hide-mode-prefix: true;
 }
 @theme "~/.config/rofi/material-ocean.rasi"