mirror of
https://github.imc.re/void-land/hyprland-void-dots
synced 2025-04-26 15:13:42 +02:00
chore: setup hyprland repo for go setup
This commit is contained in:
parent
1a20366108
commit
f7b7da9cf4
2 changed files with 120 additions and 54 deletions
130
setup-go/main.go
130
setup-go/main.go
|
@ -4,27 +4,29 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"hyprland-setup/utils"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
updateXbps bool
|
||||
updatePkgs bool
|
||||
clearCache bool
|
||||
disableGrubMenu bool
|
||||
ttfFontsDir = "host/ui/fonts/TTF"
|
||||
const (
|
||||
installHyprland bool = true
|
||||
installPipewire bool = true
|
||||
updateXbps bool = false
|
||||
updatePkgs bool = false
|
||||
clearCache bool = false
|
||||
disableGrubMenu bool = false
|
||||
ttfFontsDir string = "host/ui/fonts/TTF"
|
||||
hyprlandRepo string = "https://github.com/void-land/hyprland-void-packages/releases/latest/download/"
|
||||
)
|
||||
|
||||
var packages = map[string][]string{
|
||||
"VOID_REPOS": {"void-repo-multilib", "void-repo-nonfree"},
|
||||
"CONTAINER_PACKAGES": {"podman", "podman-compose", "catatonit"},
|
||||
"BASE_PACKAGES": {"fontconfig", "fontconfig-32bit", "inetutils", "v4l2loopback", "bind-utils", "zellij", "bat", "dust", "aria2", "fzf", "neofetch", "bat", "zsh", "fish-shell", "brightnessctl", "bluez", "cronie", "git", "stow", "eza", "dbus", "seatd", "elogind", "polkit", "NetworkManager", "gnome-keyring", "polkit-gnome", "pipewire", "wireplumber", "inotify-tools", "xorg", "gnome-keyring", "polkit-gnome", "mtpfs", "ffmpeg", "libnotify"},
|
||||
"DEVEL_PACKAGES": {"glib", "pango-devel", "gdk-pixbuf-devel", "libdbusmenu-gtk3-devel", "glib-devel", "gtk+3-devel", "gtk-layer-shell-devel", "base-devel", "startup-notification-devel", "cairo-devel", "xcb-util-devel", "xcb-util-cursor-devel", "xcb-util-xrm-devel", "xcb-util-wm-devel"},
|
||||
"AMD_DRIVERS": {"opencl2-headers", "mesa-32bit", "mesa-dri", "mesa-vaapi", "mesa-dri-32bit", "mesa-vaapi-32bit", "libglvnd-32bit", "libglapi-32bit", "opencv", "Vulkan-Headers", "Vulkan-Tools", "Vulkan-ValidationLayers-32bit", "mesa-vulkan-radeon", "mesa-vulkan-radeon-32bit", "vulkan-loader", "vulkan-loader-32bit", "libspa-vulkan", "libspa-vulkan-32bit", "amdvlk"},
|
||||
"HYPRLAND_PACKAGES": {"qt5-wayland", "qt6-wayland", "qt6ct", "qt5ct", "noto-fonts-emoji", "ddcutil", "socat", "eww", "nerd-fonts-symbols-ttf", "Waybar", "avizo", "dunst", "swaybg", "mpvpaper", "grim", "jq", "slurp", "cliphist", "wl-clipboard", "swayidle", "pavucontrol", "nemo", "eog", "pavucontrol", "evince", "xorg-server-xwayland", "xdg-desktop-portal-gtk", "xdg-desktop-portal-wlr", "xdg-utils", "xdg-user-dirs", "xdg-user-dirs-gtk", "qt5-x11extras"},
|
||||
"SYSTEM_APPS": {"alacritty", "octoxbps", "blueman", "wifish", "wpa_gui", "glow"},
|
||||
"VOID_REPOS": {"void-repo-multilib2", "void-repo-nonfree"},
|
||||
"CONTAINER_PACKAGES": {"podman", "podman-compose", "catatonit"},
|
||||
"BASE_PACKAGES": {"fontconfig", "fontconfig-32bit", "inetutils", "v4l2loopback", "bind-utils", "zellij", "bat", "dust", "aria2", "fzf", "neofetch", "bat", "zsh", "fish-shell", "brightnessctl", "bluez", "cronie", "git", "stow", "eza", "dbus", "seatd", "elogind", "polkit", "NetworkManager", "gnome-keyring", "polkit-gnome", "pipewire", "wireplumber", "inotify-tools", "xorg", "gnome-keyring", "polkit-gnome", "mtpfs", "ffmpeg", "libnotify"},
|
||||
"DEVEL_PACKAGES": {"cmake", "glib", "pango-devel", "gdk-pixbuf-devel", "libdbusmenu-gtk3-devel", "glib-devel", "gtk+3-devel", "gtk-layer-shell-devel", "base-devel", "startup-notification-devel", "cairo-devel", "xcb-util-devel", "xcb-util-cursor-devel", "xcb-util-xrm-devel", "xcb-util-wm-devel"},
|
||||
"AMD_DRIVERS": {"opencl2-headers", "mesa-32bit", "mesa-dri", "mesa-vaapi", "mesa-dri-32bit", "mesa-vaapi-32bit", "libglvnd-32bit", "libglapi-32bit", "opencv", "Vulkan-Headers", "Vulkan-Tools", "Vulkan-ValidationLayers-32bit", "mesa-vulkan-radeon", "mesa-vulkan-radeon-32bit", "vulkan-loader", "vulkan-loader-32bit", "libspa-vulkan", "libspa-vulkan-32bit", "amdvlk"},
|
||||
"HYPRLAND_REQUIRED_PACKAGES": {"qt5-wayland", "qt6-wayland", "qt6ct", "qt5ct", "noto-fonts-emoji", "ddcutil", "socat", "eww", "nerd-fonts-symbols-ttf", "Waybar", "avizo", "dunst", "swaybg", "mpvpaper", "grim", "jq", "slurp", "cliphist", "wl-clipboard", "swayidle", "pavucontrol", "nemo", "eog", "pavucontrol", "evince", "xorg-server-xwayland", "xdg-desktop-portal-gtk", "xdg-desktop-portal-wlr", "xdg-utils", "xdg-user-dirs", "xdg-user-dirs-gtk", "qt5-x11extras"},
|
||||
"SYSTEM_APPS": {"alacritty", "octoxbps", "blueman", "wifish", "wpa_gui", "glow"},
|
||||
}
|
||||
|
||||
var services = []string{
|
||||
|
@ -39,8 +41,11 @@ var services = []string{
|
|||
|
||||
func main() {
|
||||
fullInstall := flag.Bool("s", false, "Full install")
|
||||
|
||||
installFonts := flag.Bool("f", false, "Install host fonts")
|
||||
|
||||
showHelp := flag.Bool("h", false, "Show help")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *showHelp || (!*fullInstall && !*installFonts) {
|
||||
|
@ -52,21 +57,25 @@ func main() {
|
|||
if *fullInstall {
|
||||
utils.CheckSudo()
|
||||
|
||||
updateSystem()
|
||||
// updateSystem()
|
||||
|
||||
clearPkgsCache()
|
||||
// clearPackagesCache()
|
||||
|
||||
installPackages()
|
||||
// setupHyprlandRepo()
|
||||
|
||||
addUserToGroups()
|
||||
// syncXbps()
|
||||
|
||||
enableServices()
|
||||
setupPackages()
|
||||
|
||||
enablePipewire()
|
||||
// addUserToGroups()
|
||||
|
||||
// setupServices()
|
||||
|
||||
setupPipewire()
|
||||
|
||||
disableGrubMenuFunc()
|
||||
|
||||
log.Println("Setup is done, please log out and log in")
|
||||
utils.LogColoredMessage("Setup is done, please log out and log in", utils.ColorGreen)
|
||||
}
|
||||
|
||||
if *installFonts {
|
||||
|
@ -101,7 +110,7 @@ func updateSystem() {
|
|||
}
|
||||
}
|
||||
|
||||
func clearPkgsCache() {
|
||||
func clearPackagesCache() {
|
||||
if clearCache {
|
||||
utils.LogMessage("Clear package manager cache \n")
|
||||
|
||||
|
@ -115,77 +124,96 @@ func clearPkgsCache() {
|
|||
}
|
||||
}
|
||||
|
||||
func packagesInstaller(packageList []string) {
|
||||
utils.LogColoredMessage(fmt.Sprintf("Installing %s \n", packageList), utils.ColorGreen)
|
||||
func setupHyprlandRepo() {
|
||||
utils.LogColoredMessage("Installing hyprland repo \n")
|
||||
|
||||
args := append([]string{"xbps-install", "-Sy"}, packageList...)
|
||||
filePath := "/etc/xbps.d/hyprland-packages.conf"
|
||||
|
||||
utils.RunCommand("sudo", args...)
|
||||
content := fmt.Sprintf("repository=%s", hyprlandRepo)
|
||||
|
||||
// utils.LogColoredMessage(fmt.Sprintf("%s packages installed", setName), utils.ColorGreen)
|
||||
err := utils.WriteToFile(filePath, content)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
} else {
|
||||
utils.LogColoredMessage(fmt.Sprintf("Repo added to %s \n", filePath), utils.ColorGreen)
|
||||
}
|
||||
}
|
||||
|
||||
func installPackages() {
|
||||
func syncXbps() {
|
||||
utils.LogColoredMessage("Syncing repos \n")
|
||||
|
||||
utils.RunCommand("sudo", "xbps-install", "-S")
|
||||
}
|
||||
|
||||
func setupPackages() {
|
||||
utils.LogColoredMessage("Installing required packages \n")
|
||||
|
||||
for _, packageSet := range packages {
|
||||
packagesInstaller(packageSet)
|
||||
for _, packageList := range packages {
|
||||
args := append([]string{"xbps-install", "-y"}, packageList...)
|
||||
|
||||
utils.RunCommand("sudo", args...)
|
||||
}
|
||||
}
|
||||
|
||||
func addUserToGroups() {
|
||||
utils.LogMessage("Add user to needed groups")
|
||||
utils.LogMessage("Add user to needed groups \n")
|
||||
|
||||
utils.RunCommand("sudo", "usermod", "-a", os.Getenv("USER"), "-G", "_seatd")
|
||||
utils.RunCommand("sudo", "usermod", "-a", os.Getenv("USER"), "-G", "bluetooth")
|
||||
utils.LogMessage("User added to needed groups")
|
||||
|
||||
utils.LogMessage("User added to needed groups \n")
|
||||
}
|
||||
|
||||
func enableServices() {
|
||||
func setupServices() {
|
||||
utils.LogMessage("Enable services")
|
||||
|
||||
for _, service := range services {
|
||||
targetService := filepath.Join("/etc/sv", service)
|
||||
|
||||
if _, err := os.Stat(filepath.Join("/var/service", service)); err == nil {
|
||||
utils.LogMessage(fmt.Sprintf("Service %s already exists, skipping", targetService))
|
||||
|
||||
} else if _, err := os.Stat(targetService); os.IsNotExist(err) {
|
||||
utils.LogMessage(fmt.Sprintf("Service %s is not installed", targetService))
|
||||
} else {
|
||||
utils.RunCommand("sudo", "ln", "-s", targetService, "/var/service")
|
||||
|
||||
utils.LogMessage(fmt.Sprintf("Service %s enabled", service))
|
||||
}
|
||||
}
|
||||
|
||||
utils.LogMessage("Services enabled")
|
||||
}
|
||||
|
||||
func enablePipewire() {
|
||||
utils.LogMessage("Enable Pipewire")
|
||||
utils.RunCommand("sudo", "ln", "-s", "/usr/share/applications/pipewire.desktop", "/etc/xdg/autostart")
|
||||
utils.RunCommand("sudo", "ln", "-s", "/usr/share/applications/pipewire-pulse.desktop", "/etc/xdg/autostart")
|
||||
utils.RunCommand("sudo", "ln", "-s", "/usr/share/applications/wireplumber.desktop", "/etc/xdg/autostart")
|
||||
utils.LogMessage("Pipewire enabled")
|
||||
func setupPipewire() {
|
||||
if installPipewire {
|
||||
utils.LogMessage("Setup pipwire \n")
|
||||
|
||||
utils.RunCommand("sudo", "ln", "-sf", "/usr/share/applications/pipewire.desktop", "/etc/xdg/autostart")
|
||||
utils.RunCommand("sudo", "ln", "-sf", "/usr/share/applications/pipewire-pulse.desktop", "/etc/xdg/autostart")
|
||||
utils.RunCommand("sudo", "ln", "-sf", "/usr/share/applications/wireplumber.desktop", "/etc/xdg/autostart")
|
||||
} else {
|
||||
utils.LogColoredMessage("Skipping pipewire setup \n", utils.ColorRed)
|
||||
}
|
||||
}
|
||||
|
||||
func disableGrubMenuFunc() {
|
||||
if disableGrubMenu {
|
||||
utils.LogMessage("Disable grub menu")
|
||||
appendToFile("/etc/default/grub", "GRUB_TIMEOUT=0")
|
||||
appendToFile("/etc/default/grub", "GRUB_TIMEOUT_STYLE=hidden")
|
||||
appendToFile("/etc/default/grub", `GRUB_CMDLINE_LINUX_DEFAULT="loglevel=1 quiet splash"`)
|
||||
|
||||
utils.AppendToFile("/etc/default/grub", "GRUB_TIMEOUT=0")
|
||||
utils.AppendToFile("/etc/default/grub", "GRUB_TIMEOUT_STYLE=hidden")
|
||||
utils.AppendToFile("/etc/default/grub", `GRUB_CMDLINE_LINUX_DEFAULT="loglevel=1 quiet splash"`)
|
||||
|
||||
utils.RunCommand("sudo", "update-grub")
|
||||
|
||||
utils.LogMessage("Grub menu disabled")
|
||||
} else {
|
||||
utils.LogMessage("Skipping grub menu disable")
|
||||
utils.LogColoredMessage("Skipping grub menu disable \n", utils.ColorRed)
|
||||
}
|
||||
}
|
||||
|
||||
func appendToFile(filename, text string) {
|
||||
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644)
|
||||
utils.Check(err, fmt.Sprintf("open file %s", filename))
|
||||
defer f.Close()
|
||||
_, err = f.WriteString(text + "\n")
|
||||
utils.Check(err, fmt.Sprintf("write to file %s", filename))
|
||||
}
|
||||
|
||||
func installTtfFonts() {
|
||||
files, err := filepath.Glob(filepath.Join(ttfFontsDir, "*"))
|
||||
|
||||
|
|
|
@ -49,11 +49,49 @@ func Check(err error, message string) {
|
|||
}
|
||||
|
||||
func RunCommand(cmd string, args ...string) {
|
||||
LogMessage(fmt.Sprintf("Running command: %s %s", cmd, strings.Join(args, " ")))
|
||||
LogColoredMessage(fmt.Sprintf("Running command: %s %s", cmd, strings.Join(args, " ")), ColorPurple)
|
||||
|
||||
out, err := exec.Command(cmd, args...).CombinedOutput()
|
||||
|
||||
Check(err, fmt.Sprintf("%s %s", cmd, strings.Join(args, " ")))
|
||||
if err != nil {
|
||||
// LogMessage(fmt.Sprintf("Command failed: %s %s\nError: %v", cmd, strings.Join(args, " "), err))
|
||||
|
||||
LogMessage(string(out))
|
||||
LogColoredMessage(fmt.Sprintf("Error Output: %s", string(out)), ColorRed)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if len(out) > 0 {
|
||||
LogColoredMessage(string(out), ColorCyan)
|
||||
}
|
||||
}
|
||||
|
||||
func WriteToFile(filePath, content string) error {
|
||||
file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
_, err = file.WriteString(content)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write to file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func AppendToFile(filename, text string) {
|
||||
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644)
|
||||
|
||||
Check(err, fmt.Sprintf("open file %s", filename))
|
||||
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.WriteString(text + "\n")
|
||||
|
||||
Check(err, fmt.Sprintf("write to file %s", filename))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue