Implemented autostart

This commit is contained in:
2025-03-17 17:35:14 +01:00
parent 53c501a2cb
commit 2c30cd770f
4 changed files with 33 additions and 1 deletions

26
src/autostart.lua Normal file
View File

@@ -0,0 +1,26 @@
local io = require('io')
local spawn = require('awful').spawn.spawn
local readable = require('gears.filesystem').file_readable
local confdir = require('src.util.path').conf_dir
local xres_name = 'awesome.did_autostart'
-- check
local xres_fp = io.popen('xrdb -query')
if xres_fp == nil then return end
local xres = xres_fp:read('*a')
if xres:match(xres_name) then return end
-- set
xres_fp = io.popen('xrdb -merge', 'w')
if xres_fp == nil then return end
xres_fp:write(xres_name, ':true')
xres_fp:close()
local autostart_file = confdir .. '/autostart'
if readable(autostart_file) then
for line in io.lines(autostart_file, "*l") do
---@cast line string
if line:len() > 0 then
spawn(line)
end
end
end