Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions rules/gnome.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
-- #![Sudo]
-- #![Unsafe]


local tmpDir = "/tmp/spito-gnome"
local whiteSurGtkPath = tmpDir .. "/WhiteSur-gtk-theme"

function main()
--- temporary commented because it takes a lot of time
--local err = api.pkg.install("gnome", "gdm")
if err then
api.info.error(err)
return false
end

err = prepareWhiteSurGtk()
if err then
api.info.error(err)
return false
end

err = whiteSurGtk()
if err then
api.info.error(err)
return false
end

err = api.daemon.restart("gdm")
if err then
api.info.error(err)
return false
end

return true
end

function prepareWhiteSurGtk()
require_file("rules/stopAndDisableDMs.lua")

-- I used api.sh in odert to avoid reverting it later
local mkDirCommand = "mkdir -p " .. tmpDir
local gitCommand = "git clone https://github.com/vinceliuice/WhiteSur-gtk-theme " .. whiteSurGtkPath .. " || (cd " .. whiteSurGtkPath .." && git pull)"
local _, err = api.sh.command(mkDirCommand .. " && " .. gitCommand)
if err then
api.info.log("------------------------ " .. whiteSurGtkPath)
return err
end

_, err = api.sh.command("chmod +x " .. whiteSurGtkPath .. "/tweaks.sh")
if err then
return err
end

_, err = api.sh.command("chmod +x " .. whiteSurGtkPath .. "/install.sh")
if err then
return err
end

err = putDownDMs("gdm")
if err then
return err
end

return api.daemon.start("gdm")
end

function whiteSurGtk()
local _, err = api.sh.command(whiteSurGtkPath .. "/install.sh -l")
if err then
return err
end

_, err = api.sh.command(whiteSurGtkPath .. "/tweaks.sh --gdm")
if err then
return err
end

return nil
end

function revert()
local err = prepareWhiteSurGtk()
if err then
api.info.error(err)
return false
end

_, err = api.sh.command(whiteSurGtkPath .. "/install.sh --uninstall")
if err then
api.info.error(err)
return false
end

_, err = api.sh.command(whiteSurGtkPath .. "/tweaks.sh -g --revert")
if err then
api.info.error(err)
return false
end

return true
end
38 changes: 38 additions & 0 deletions rules/stopAndDisableDMs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- stop and disable desktop managers

local DMs = {
"gdm",
"lightdm",
}

-- We return always true, because this is library
-- and when someone uses require_file it checks main function
-- btw this check should be skipped when using require_file
function main()
return true
end

--- @param dmToSkip string - name of DM to skip
function putDownDMs(dmToSkip)
dmToSkip = string.lower(dmToSkip)

for _, dm in pairs(DMs) do
if dm == dmToSkip then
goto continue
end

err = api.daemon.stop(dm)
if err then
return err
end

err = api.daemon.disable(dm)
if err then
return err
end

::continue::
end

return nil
end
24 changes: 19 additions & 5 deletions spito.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ rules:
path: rules/dbus.lua
description: ""
unsafe: false
environment: false
sudo: false
extrepo:
path: rules/extrepo.lua
description: ""
unsafe: false
environment: false
sudo: false
gnome:
path: rules/gnome.lua
description: ""
unsafe: false
environment: false
sudo: false
info:
path: rules/info.lua
description: ""
unsafe: false
environment: false
sudo: false
nerd-fonts:
path: rules/nerd-fonts.lua
description: ""
unsafe: false
extrepo:
path: rules/extrepo.lua
description: ""
unsafe: false
environment: false
sudo: false
description: ""
branch: ""
branch: main
dependencies: {}