Implemented autostart

This commit is contained in:
Mutzi 2025-03-17 17:35:14 +01:00
parent 53c501a2cb
commit 2c30cd770f
Signed by: root
GPG Key ID: 2437494E09F13876
4 changed files with 33 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
build/
.cache
backup.tar
autostart

View File

@ -12,7 +12,11 @@ testv: build
.PHONY: deploy
deploy: build
rsync -avmh --delete --exclude 'settings.lua' --include '*.lua' --include '*.so' --include '*.png' --include '*/' --include '*.rasi' --include '*.sh' --exclude '*' ./ ~/.config/awesome/
rsync -avmh --delete \
--exclude 'settings.lua' --exclude 'autostart' \
--include '*.lua' --include '*.so' --include '*.png' --include '*/' --include '*.rasi' --include '*.sh' \
--exclude '*' \
./ ~/.config/awesome/
.PHONY: build
build:

1
rc.lua
View File

@ -48,3 +48,4 @@ end)
local on_screen_connect = require('src.theme.wibar')
require('awful').screen.connect_for_each_screen(function(s) on_screen_connect(s) end)
require('awful').spawn.with_shell('xset s 0 0; xset dpms 0 0 0')
require('src.autostart')

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