From 36b86a40f8aa4a32a0ba5d45a9890507d8c42a20 Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Wed, 3 Jan 2024 00:53:26 -0500 Subject: [PATCH] return to active tag on restart --- configs/awesome/signals/init.lua | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/configs/awesome/signals/init.lua b/configs/awesome/signals/init.lua index 4740303..b79fd5b 100644 --- a/configs/awesome/signals/init.lua +++ b/configs/awesome/signals/init.lua @@ -93,3 +93,44 @@ client.connect_signal( c.border_color = Beautiful.border_normal end ) + +awesome.connect_signal( + 'exit', + function(reason_restart) + if not reason_restart then + return + end + + local file = io.open('/tmp/awesomewm-last-selected-tags', 'w+') + + for s in screen do + file:write(s.selected_tag.index, '\n') + end + + file:close() + end +) + +awesome.connect_signal( + 'startup', + function() + local file = io.open('/tmp/awesomewm-last-selected-tags', 'r') + if not file then + return + end + + local selected_tags = {} + + for line in file:lines() do + table.insert(selected_tags, tonumber(line)) + end + + for s in screen do + local i = selected_tags[s.index] + local t = s.tags[i] + t:view_only() + end + + file:close() + end +)