summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachIR <zachir@librem.one>2022-07-28 17:07:00 -0500
committerZachIR <zachir@librem.one>2022-07-28 17:07:00 -0500
commitf52ad4441f33174caa137c260eb2ecdfb33d0199 (patch)
treea7df4f5d50fc0c3ae780b6e9d1829dc1a7683d20
parentb044dcd913dc64deacef1b75924733d0a9c38f48 (diff)
rc.lua: allow using XDG for config, parse computerrc, add openbsd wibar
-rw-r--r--rc.lua161
1 files changed, 104 insertions, 57 deletions
diff --git a/rc.lua b/rc.lua
index f1622ae..97b1d59 100644
--- a/rc.lua
+++ b/rc.lua
@@ -50,7 +50,12 @@ end
-- Themes define colours, icons, font and wallpapers.
local theme = {}
theme.name = "default"
-theme.dir = string.format("%s/.config/awesome/themes/%s", os.getenv("HOME"), theme.name)
+if (os.getenv("XDG_CONFIG_HOME")) then
+ config_dir = os.getenv("XDG_CONFIG_HOME")
+else
+ config_dir = string.format("%s/.config", os.getenv("HOME"))
+end
+theme.dir = string.format("%s/awesome/themes/%s", config_dir, theme.name)
beautiful.init(theme.dir .. "/theme.lua")
beautiful.useless_gap = 5
beautiful.wallpaper = awful.util.get_configuration_dir() .. "../../background.png"
@@ -76,25 +81,6 @@ local spawnatbottom = true
-- This is used later as the default terminal and editor to run.
terminal = "st"
-function terminal_sp_cmd (spc, cmd)
- if terminal == "st" then
- cflag = "-c"
- gflag = "-g"
- xflag = "-e"
- geo = "100x30"
- elseif terminal == "alacritty" then
- cflag = "--class"
- gflag = false
- xflag = "-e"
- end
- if gflag then
- return terminal .. " " .. cflag .. " " .. spc .. " " .. \
- gflag .. " " .. geo .. " " .. xflag .. " " .. cmd
- else
- return terminal .. " " .. cflag .. " " .. spc .. " " .. \
- " " .. xflag .. " " .. cmd
- end
-end
editor = os.getenv("EDITOR") or "nvim"
editor_cmd = terminal .. " -e " .. editor
@@ -126,6 +112,45 @@ awful.layout.layouts = {
}
-- }}}
+-- Config function definitions {{{
+
+function terminal_sp_cmd (spc, cmd)
+ if terminal == "st" then
+ local cflag = "-c"
+ local gflag = "-g"
+ local xflag = "-e"
+ local geo = "100x30"
+ elseif terminal == "alacritty" then
+ local cflag = "--class"
+ local gflag = false
+ local xflag = "-e"
+ end
+ if gflag then
+ return terminal .. " " .. cflag .. " " .. spc .. " " .. \
+ gflag .. " " .. geo .. " " .. xflag .. " " .. cmd
+ else
+ return terminal .. " " .. cflag .. " " .. spc .. " " .. \
+ " " .. xflag .. " " .. cmd
+ end
+end
+
+function crcparse(substr)
+ local file=assert(io.open(config_dir .. "/computerrc","r"))
+ local line = ""
+ repeat
+ line=file:read("*line")
+ if line and line:find(string.format("^%s=",substr)) then
+ return string.sub(line,#substr + 2,-1)
+ end
+ until not line
+end
+
+function islinux ()
+ return crcparse("OS") == "Linux"
+end
+
+-- }}}
+
-- {{{ Menu
-- Create a launcher widget and a main menu
myawesomemenu = {
@@ -244,42 +269,64 @@ awful.screen.connect_for_each_screen(function(s)
-- Create the wibox
s.mywibox = awful.wibar({ position = "top", screen = s, height = 24})
- -- Add widgets to the wibox
- s.mywibox:setup {
- layout = wibox.layout.align.horizontal,
- { -- Left widgets
- layout = wibox.layout.fixed.horizontal,
- mylauncher,
- s.mytaglist,
- s.mypromptbox,
- },
- s.mytasklist, -- Middle widget
- {
- layout = wibox.layout.fixed.horizontal,
- mpd_widget,
- net_speed {
- interface = "wlan0"
- },
- ram_widget(),
- cpu_widget(),
- brightness_widget {
- program = "light",
- path_to_icon = "/usr/share/icons/Paper/scalable/status/display-brightness-symbolic.svg",
- step = 5,
- timeout = 1,
- },
- volume_widget {
- path_to_icon = "/usr/share/icons/Paper/scalable/status/audio-volume-muted-symbolic.svg",
- widget_type = "arc",
- mute_color = "#ff111111",
- },
- battery_widget { path_to_icons = "/usr/share/icons/Paper/scalable/status/" },
- mykeyboardlayout,
- wibox.widget.systray(),
- mytextclock,
- s.mylayoutbox,
- },
- }
+ if islinux() then
+ -- Add widgets to the wibox
+ s.mywibox:setup {
+ layout = wibox.layout.align.horizontal,
+ { -- Left widgets
+ layout = wibox.layout.fixed.horizontal,
+ mylauncher,
+ s.mytaglist,
+ s.mypromptbox,
+ },
+ s.mytasklist, -- Middle widget
+ {
+ layout = wibox.layout.fixed.horizontal,
+ mpd_widget,
+ net_speed {
+ interface = "wlan0"
+ },
+ ram_widget(),
+ cpu_widget(),
+ brightness_widget {
+ program = "light",
+ path_to_icon = "/usr/share/icons/Paper/scalable/status/display-brightness-symbolic.svg",
+ step = 5,
+ timeout = 1,
+ },
+ volume_widget {
+ path_to_icon = "/usr/share/icons/Paper/scalable/status/audio-volume-muted-symbolic.svg",
+ widget_type = "arc",
+ mute_color = "#ff111111",
+ },
+ battery_widget { path_to_icons = "/usr/share/icons/Paper/scalable/status/" },
+ mykeyboardlayout,
+ wibox.widget.systray(),
+ mytextclock,
+ s.mylayoutbox,
+ },
+ }
+ elseif isobsd() then
+ -- Add widgets to the wibox
+ s.mywibox:setup {
+ layout = wibox.layout.align.horizontal,
+ { -- Left widgets
+ layout = wibox.layout.fixed.horizontal,
+ mylauncher,
+ s.mytaglist,
+ s.mypromptbox,
+ },
+ s.mytasklist, -- Middle widget
+ {
+ layout = wibox.layout.fixed.horizontal,
+ mpd_widget,
+ mykeyboardlayout,
+ wibox.widget.systray(),
+ mytextclock,
+ s.mylayoutbox,
+ },
+ }
+ end
end)
-- }}}
@@ -776,7 +823,7 @@ end)
-- {{{ Autostart
-- awful.spawn.with_shell("/usr/bin/sxhkd")
-awful.spawn.with_shell("sh ~/.config/autostart.sh &")
+awful.spawn.with_shell(string.format("sh %s/autostart.sh &", config_dir))
-- }}}
-- spawn windows as slaves {{{