rc.lua cleanup

This commit is contained in:
Izaya 2021-10-25 15:25:15 +11:00
parent 266743096d
commit 7c12072e1d
1 changed files with 40 additions and 75 deletions

115
rc.lua
View File

@ -20,6 +20,16 @@ local hotkeys_popup = require("awful.hotkeys_popup")
require("awful.hotkeys_popup.keys")
local ram_widget = require("awesome-wm-widgets.ram-widget.ram-widget")
local cpu_widget = require("awesome-wm-widgets.cpu-widget.cpu-widget")
local batteryarc_widget = require("awesome-wm-widgets.batteryarc-widget.batteryarc")
local function batteryarc() -- detect if there are any batteries before showing the battery arc widget
local c = io.popen("acpi")
if c:read("*a"):len() < 1 then
return
else
return batteryarc_widget()
end
end
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
@ -49,9 +59,7 @@ end
-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
--beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
beautiful.init("/home/izaya/.config/awesome/theme.lua")
--local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), "default")
--beautiful.init(theme_path)
beautiful.init(string.format("%s/.config/awesome/theme.lua",os.getenv("HOME")))
-- This is used later as the default terminal and editor to run.
terminal = "xfce4-terminal"
@ -160,9 +168,9 @@ local tasklist_buttons = gears.table.join(
local function set_wallpaper(s)
local wpath
if s.geometry.width > s.geometry.height then -- landscape
wpath = "/home/izaya/Pictures/wp/rotation"
wpath = "/home/izaya/Nextcloud/Pictures/Wallpapers"
else
wpath = "/home/izaya/Pictures/wp/rotation/portrait"
wpath = "/home/izaya/Nextcloud/Pictures/Wallpapers/Phone"
end
local tWP = {}
for line in io.popen(string.format('ls "%s"',wpath),"r"):read("*a"):gmatch("([^\n]+)") do
@ -194,18 +202,26 @@ awful.screen.connect_for_each_screen(function(s)
-- Each screen has its own tag table.
local tags = {}
if s.geometry.width > s.geometry.height then -- landscape
for i = 1, 2 do
if screen:count() > 1 then
if s.geometry.width > s.geometry.height then -- landscape
for i = 1, 2 do
tags[#tags+1] = tostring(workspaceCounter)
workspaceCounter = workspaceCounter + 1
end
awful.tag(tags, s, awful.layout.suit.floating)
else -- portrait
for i = 1, 4 do
tags[#tags+1] = tostring(workspaceCounter)
workspaceCounter = workspaceCounter + 1
end
awful.tag(tags, s, awful.layout.suit.fair.horizontal)
end
else
for i = 1, 10 do
tags[#tags+1] = tostring(workspaceCounter)
workspaceCounter = workspaceCounter + 1
end
awful.tag(tags, s, awful.layout.suit.floating)
else -- portrait
for i = 1, 4 do
tags[#tags+1] = tostring(workspaceCounter)
workspaceCounter = workspaceCounter + 1
end
awful.tag(tags, s, awful.layout.suit.fair.horizontal)
awful.tag(tags, s, awful.layout.suit.fair)
end
-- Create a promptbox for each screen
@ -236,44 +252,6 @@ awful.screen.connect_for_each_screen(function(s)
-- Create the wibox
s.mywibox = awful.wibar({ position = "top", screen = s})
-- Add widgets to the wibox
--[[
if s.geometry.width > s.geometry.height then -- landscape
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
},
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
cpu_widget(),
ram_widget(),
wibox.widget.systray(),
mytextclock,
s.mylayoutbox,
},
}
else
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
},
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
s.mylayoutbox,
},
}
end
]]
local w,h = root.size()
if s.index == awful.screen.getbycoord(w,1) then -- top right
mysystray.set_screen(s)
@ -291,6 +269,7 @@ awful.screen.connect_for_each_screen(function(s)
mysystray,
cpu_widget(),
ram_widget(),
batteryarc(),
mytextclock,
s.mylayoutbox,
},
@ -707,29 +686,15 @@ client.connect_signal("request::titlebars", function(c)
layout = wibox.layout.align.horizontal
}
end)
--os.execute("rwallpaper.sh")
-- Enable sloppy focus, so that focus follows mouse.
--[[
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
]]
-- }}}
awful.spawn.with_shell(
'if (xrdb -query | grep -q "^awesome\\.started:\\s*true$"); then exit; fi;' ..
'xrdb -merge <<< "awesome.started:true";' ..
-- list each of your autostart commands, followed by ; inside single quotes, followed by ..
'corectrl' ..
'nextcloud' ..
'SSH_ASKPASS_REQUIRE=force ssh-add' ..
'xinput set-prop "Logitech MX518 Gaming Mouse" "libinput Accel Profile Enabled" 0, 0' ..
'dex --environment Awesome --autostart --search-paths "$XDG_CONFIG_DIRS/autostart:$XDG_CONFIG_HOME/autostart"' -- https://github.com/jceb/dex
)
awful.spawn.with_shell(
'if (xrdb -query | grep -q "^awesome\\.started:\\s*true$"); then exit; fi;' ..
'xrdb -merge <<< "awesome.started:true";' ..
'corectrl' ..
'nextcloud' ..
'SSH_ASKPASS_REQUIRE=force ssh-add' ..
'xinput set-prop "Logitech MX518 Gaming Mouse" "libinput Accel Profile Enabled" 0, 0' ..
'dex --environment Awesome --autostart --search-paths "$XDG_CONFIG_DIRS/autostart:$XDG_CONFIG_HOME/autostart"' -- https://github.com/jceb/dex
)
gears.wallpaper.set("#000000")
--[[
awful.spawn.with_shell("corectrl")