From 6bbcbb74a1445ca395beba90c802aa33bf5f5412 Mon Sep 17 00:00:00 2001 From: LycanDarko Date: Mon, 2 Oct 2023 17:01:28 -0700 Subject: [PATCH 1/6] Each screen only highlights the tags it is displaying. --- rabbithole/components/widgets/taglist/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rabbithole/components/widgets/taglist/init.lua b/rabbithole/components/widgets/taglist/init.lua index b49f1931..42ad419b 100644 --- a/rabbithole/components/widgets/taglist/init.lua +++ b/rabbithole/components/widgets/taglist/init.lua @@ -129,8 +129,20 @@ function TaglistController:create_tag_callback(tag_template, tag, index, objects tag:connect_signal('property::selected', function() if tag.selected then animation.target = 1 + -- Highlight the tag on its own screen + for _, screen in ipairs(tag.screen.outputs) do + if screen == self.screen then + tag_template.bg = self.colors.blend_colors(beautiful.bg_normal, beautiful.bg_focus, 1) + end + end else animation.target = 0 + -- Reset the tag color on its own screen + for _, screen in ipairs(tag.screen.outputs) do + if screen == self.screen then + tag_template.bg = self.colors.blend_colors(beautiful.bg_normal, beautiful.bg_focus, 0) + end + end end end) From 9b05acec3e16de399777c9082b1483040ef49c8e Mon Sep 17 00:00:00 2001 From: LycanDarko Date: Mon, 2 Oct 2023 19:31:42 -0700 Subject: [PATCH 2/6] ScrOCR sends notifications over dbus --- scripts/scrocr.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/scrocr.sh b/scripts/scrocr.sh index c6b6a0eb..8ba5cb8a 100755 --- a/scripts/scrocr.sh +++ b/scripts/scrocr.sh @@ -17,4 +17,15 @@ mogrify -modulate 100,0 -resize 400% "$SCR_IMG".png # postprocess to prepare for tesseract -l "$LANG" "$SCR_IMG".png stdout | xsel -bi +# Send D-Bus message to notify the user +dbus-send --type=method_call --dest=org.freedesktop.Notifications \ + /org/freedesktop/Notifications \ + org.freedesktop.Notifications.Notify \ + string:"ScrOCR" uint32:1 \ + string:"" \ + string:"OCR Completed" \ + string:"Selected area has been converted to text by OCR and dumped to your clipboard." \ + array:string:"" \ + dict:string:string:"","" int32:5000 + exit From e8313d33c76ed85ffc59feb74231aab8cd0a4669 Mon Sep 17 00:00:00 2001 From: LycanDarko Date: Mon, 2 Oct 2023 20:14:46 -0700 Subject: [PATCH 3/6] Cleanup --- .../components/wiboxes/bars/mini-bar.lua.bak | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 rabbithole/components/wiboxes/bars/mini-bar.lua.bak diff --git a/rabbithole/components/wiboxes/bars/mini-bar.lua.bak b/rabbithole/components/wiboxes/bars/mini-bar.lua.bak deleted file mode 100644 index 1cb46296..00000000 --- a/rabbithole/components/wiboxes/bars/mini-bar.lua.bak +++ /dev/null @@ -1,49 +0,0 @@ -local awful = require("awful") -local wibox = require("wibox") -local dpi = require("beautiful").xresources.apply_dpi -local gears = require("gears") -local beautiful = require("beautiful") -local darken = require("sub.nice.colors").darken - -local minibar = {} - -function minibar.new(options, - settings, - rabbithole__services__color, - rabbithole__services__widetect - ) - - local minibar_size = dpi(34) or settings.minibar_size - local colors = rabbithole__services__color - local widetect = rabbithole__services__widetect - local minibar = awful.popup({ - screen = options.screen, - widget = options.widget or wibox.container.background, - ontop = false, - visible = true, - maximum_height = dpi(minibar_size), - minimum_height = dpi(minibar_size), - placement = function(c) - options.placement(c, { - margins = dpi(2) - }) - end, - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 10) - end, - --bg = colors.twocolortrue3d(beautiful.base_color, beautiful.secondary_color, minibar_size), - border_width = dpi(0.5), - border_color = darken(beautiful.base_color, 20), - }) - minibar:struts{top = dpi(38)} - - return minibar -end - -setmetatable(minibar, { - __call = function(self, options) - return self.new(options) - end -}) - -return minibar From f5605d29d193302cc298c65dab23eb40e8005755 Mon Sep 17 00:00:00 2001 From: LycanDarko Date: Mon, 2 Oct 2023 20:42:19 -0700 Subject: [PATCH 4/6] Made monitor detect service and injected into environment. --- rabbithole/environment.lua | 3 ++- rabbithole/services/detect-monitors.lua | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 rabbithole/services/detect-monitors.lua diff --git a/rabbithole/environment.lua b/rabbithole/environment.lua index af0b7168..fabfd30b 100644 --- a/rabbithole/environment.lua +++ b/rabbithole/environment.lua @@ -7,7 +7,8 @@ function Environment.new( rabbithole__ui__default, rabbithole__services__global, rabbithole__services__sloppy___focus, - rabbithole__services__auto___focus + rabbithole__services__auto___focus, + rabbithole__services__detect___monitors ) local self = setmetatable({}, Environment) diff --git a/rabbithole/services/detect-monitors.lua b/rabbithole/services/detect-monitors.lua new file mode 100644 index 00000000..c73f086a --- /dev/null +++ b/rabbithole/services/detect-monitors.lua @@ -0,0 +1,18 @@ +local awful = require("awful") +local naughty = require("naughty") + +local function setup_screens() + awful.spawn("autorandr --change") +end + +return setmetatable({}, { + __constructor = function() + screen.connect_signal("list", function() + naughty.notify({ + title = "Screen setup changed", + text = "Configuring displays..." + }) + setup_screens() + end) + end, +}) From 9f8a9bb8a8938592019564f5b015cfb6189fa86b Mon Sep 17 00:00:00 2001 From: LycanDarko Date: Mon, 2 Oct 2023 23:18:51 -0700 Subject: [PATCH 5/6] 3rd different method of solving the auto-detection of monitors.. --- rabbithole/services/detect-monitors.lua | 49 +++++++++++++++++++------ rabbithole/ui/default/center.lua | 1 - rabbithole/ui/default/init.lua | 28 +++++++------- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/rabbithole/services/detect-monitors.lua b/rabbithole/services/detect-monitors.lua index c73f086a..bf39f9ad 100644 --- a/rabbithole/services/detect-monitors.lua +++ b/rabbithole/services/detect-monitors.lua @@ -1,18 +1,45 @@ local awful = require("awful") local naughty = require("naughty") +local gears = require("gears") -local function setup_screens() - awful.spawn("autorandr --change") +local DetectMonitor = {} +DetectMonitor.__index = DetectMonitor + +function DetectMonitor.new() + return setmetatable({}, DetectMonitor) +end + +function DetectMonitor.setup_screens() + -- Query connected screens + awful.spawn.easy_async_with_shell("xrandr -q | grep ' connected'", function(stdout) + local screens = gears.string.split(stdout, "\n") + for _, line in pairs(screens) do + local screen_name = line:match("^(.-) connected") + if screen_name then + -- Find and set the highest available resolution for the connected screen + local max_res = line:match("%d+x%d+") + awful.spawn.easy_async_with_shell("xrandr --output " .. screen_name .. " --mode " .. max_res, function() + -- Save the configuration using autorandr + awful.spawn.easy_async_with_shell("autorandr --save " .. screen_name, function() + naughty.notify({ title = "Monitor Configuration", text = "Applied and saved configuration for " .. screen_name }) + end) + end) + end + end + end) end -return setmetatable({}, { - __constructor = function() - screen.connect_signal("list", function() - naughty.notify({ - title = "Screen setup changed", - text = "Configuring displays..." - }) - setup_screens() - end) +-- Listen to udev events for monitor changes +awful.spawn.with_line_callback("stdbuf -oL udevadm monitor --property --subsystem-match=drm", { + stdout = function(line) + -- Check for the CHANGE event related to display connection/disconnection + if line:match("ACTION=change") then + DetectMonitor.setup_screens() + end end, + stderr = function(line) + naughty.notify({ title = "Monitor Error", text = line, preset = naughty.config.presets.critical }) + end }) + +return DetectMonitor diff --git a/rabbithole/ui/default/center.lua b/rabbithole/ui/default/center.lua index 65d3aeed..6bed066c 100644 --- a/rabbithole/ui/default/center.lua +++ b/rabbithole/ui/default/center.lua @@ -1,5 +1,4 @@ local wibox = require("wibox") -local layoutlist_widget = require("rabbithole.components.widgets.layout_list") return setmetatable({}, { __constructor = function( diff --git a/rabbithole/ui/default/init.lua b/rabbithole/ui/default/init.lua index fee1a41f..cdcf3c18 100644 --- a/rabbithole/ui/default/init.lua +++ b/rabbithole/ui/default/init.lua @@ -3,7 +3,6 @@ local beautiful = require("beautiful") local bling = require("sub.bling") local dropdown = require("rabbithole.services.dropdown") - local UserInterface = {} UserInterface.__index = UserInterface @@ -16,7 +15,8 @@ function UserInterface.new( --rabbithole__ui__default__titlebar -- Using nice as titlebars for now, but standard titlebars are still available if desired ) awful.screen.connect_for_each_screen(function(s) - + -- set auto dpi detection for each screen for consistent UserInterface + --s:set_auto_dpi_enabled(true) workspaceManagerService:assignWorkspaceTagsToScreens() -- initialize left and right bars for first screen only, and taglist widget for all screens @@ -30,18 +30,18 @@ function UserInterface.new( s.dropdown = dropdown({app=settings.default_programs.terminal, argname="--title %s", extra="--class Dropdown -e tmux", visible=true, height=0.9, screen = s }) -- set dpi of screens - local resolution = s.geometry.width * s.geometry.height - local dpi - - if resolution > 1920 * 1080 then - dpi = 144 -- or whatever value you want for high DPI screens - elseif resolution > 1366 * 768 then - dpi = 141 -- or whatever value you want for medium DPI screens (1080p laptops) - else - dpi = 110 --or whatever dpi value you want for low DPI screens - end - - beautiful.xresources.set_dpi(dpi, s) + --local resolution = s.geometry.width * s.geometry.height + --local dpi +-- + --if resolution > 1920 * 1080 then + -- dpi = 144 -- or whatever value you want for high DPI screens + --elseif resolution > 1366 * 768 then + -- dpi = 141 -- or whatever value you want for medium DPI screens (1080p laptops) + --else + -- dpi = 110 --or whatever dpi value you want for low DPI screens + --end +-- + --beautiful.xresources.set_dpi(dpi, s) bling.module.wallpaper.setup { screen = s, From 597bcff6374da41ebd90d2f985ba074e9c6669ed Mon Sep 17 00:00:00 2001 From: LycanDarko Date: Mon, 2 Oct 2023 23:35:34 -0700 Subject: [PATCH 6/6] Suck it, hot plugging monitors is back, in pure Lua. We don't need LxQt --- rabbithole/services/detect-monitors.lua | 28 ++++++++++++++++++++----- rabbithole/ui/default/init.lua | 24 ++++++++++----------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/rabbithole/services/detect-monitors.lua b/rabbithole/services/detect-monitors.lua index bf39f9ad..64c4d1d8 100644 --- a/rabbithole/services/detect-monitors.lua +++ b/rabbithole/services/detect-monitors.lua @@ -1,3 +1,11 @@ +--[[ detect-monitors.lua +This is the magical service that listens to udev events for detecting monitors, then +automatically configures them and sstores the configuration on the local machine via autorandr. + +If LxQt can do it, Lycan can do it. +]] + + local awful = require("awful") local naughty = require("naughty") local gears = require("gears") @@ -5,21 +13,21 @@ local gears = require("gears") local DetectMonitor = {} DetectMonitor.__index = DetectMonitor + function DetectMonitor.new() return setmetatable({}, DetectMonitor) end function DetectMonitor.setup_screens() - -- Query connected screens awful.spawn.easy_async_with_shell("xrandr -q | grep ' connected'", function(stdout) local screens = gears.string.split(stdout, "\n") for _, line in pairs(screens) do local screen_name = line:match("^(.-) connected") if screen_name then - -- Find and set the highest available resolution for the connected screen + -- finds and sets the highest available resolution for the connected screen local max_res = line:match("%d+x%d+") awful.spawn.easy_async_with_shell("xrandr --output " .. screen_name .. " --mode " .. max_res, function() - -- Save the configuration using autorandr + -- save the screen config w/ autorandr awful.spawn.easy_async_with_shell("autorandr --save " .. screen_name, function() naughty.notify({ title = "Monitor Configuration", text = "Applied and saved configuration for " .. screen_name }) end) @@ -29,12 +37,22 @@ function DetectMonitor.setup_screens() end) end +-- Debouncing timer to prevent multiple calls to setup_screens and multiple notifications +local debounce_timer = nil +local debounce_time = 2 -- in seconds + -- Listen to udev events for monitor changes awful.spawn.with_line_callback("stdbuf -oL udevadm monitor --property --subsystem-match=drm", { stdout = function(line) - -- Check for the CHANGE event related to display connection/disconnection if line:match("ACTION=change") then - DetectMonitor.setup_screens() + if debounce_timer then + debounce_timer:stop() + debounce_timer = nil + end + + debounce_timer = gears.timer.start_new(debounce_time, function() + DetectMonitor.setup_screens() + end) end end, stderr = function(line) diff --git a/rabbithole/ui/default/init.lua b/rabbithole/ui/default/init.lua index cdcf3c18..c74a9211 100644 --- a/rabbithole/ui/default/init.lua +++ b/rabbithole/ui/default/init.lua @@ -30,18 +30,18 @@ function UserInterface.new( s.dropdown = dropdown({app=settings.default_programs.terminal, argname="--title %s", extra="--class Dropdown -e tmux", visible=true, height=0.9, screen = s }) -- set dpi of screens - --local resolution = s.geometry.width * s.geometry.height - --local dpi --- - --if resolution > 1920 * 1080 then - -- dpi = 144 -- or whatever value you want for high DPI screens - --elseif resolution > 1366 * 768 then - -- dpi = 141 -- or whatever value you want for medium DPI screens (1080p laptops) - --else - -- dpi = 110 --or whatever dpi value you want for low DPI screens - --end --- - --beautiful.xresources.set_dpi(dpi, s) + local resolution = s.geometry.width * s.geometry.height + local dpi + + if resolution > 1920 * 1080 then + dpi = 144 -- or whatever value you want for high DPI screens + elseif resolution > 1366 * 768 then + dpi = 141 -- or whatever value you want for medium DPI screens (1080p laptops) + else + dpi = 110 --or whatever dpi value you want for low DPI screens + end + + beautiful.xresources.set_dpi(dpi, s) bling.module.wallpaper.setup { screen = s,