From 70af64d9635b87e77bdcb132f74de1d2aa588a64 Mon Sep 17 00:00:00 2001 From: Arda Atci Date: Sat, 23 Dec 2023 20:01:51 +0300 Subject: [PATCH] finalizing --- Makefile | 37 +++++++++++++++++++++++++++++++++++++ main.go | 16 ++++++++++++++-- settings/options.go | 12 ++++++++++-- utils/utils.go | 2 +- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e2accab --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +PROG = physettings + +ifndef $(GOPATH) + GOPATH=$(shell go env GOPATH) + export GOPATH +endif + +rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) + +SRC = $(call rwildcard,.,*.go) + +PREFIX ?= /usr + +GOCMD = go + +VERSION ?= 1.0.0 + +build: $(SRC) + GOOS=linux GOARCH=amd64 ${GOCMD} build -o ${PROG} main.go + +deps: $(SRC) + ${GOCMD} get github.com/gotk3/gotk3@latest + +clean: + rm -f ${PROG} + +all: deps build + +install: + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f ${PROG} $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/${PROG} + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/${PROG} + +.PHONY: all build deps clean install uninstall diff --git a/main.go b/main.go index 6819dbe..82fc68c 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "log" "github.com/gotk3/gotk3/gtk" - p "physettings/settings" + p "github.com/physettings-gtk/settings" ) const ( @@ -11,6 +11,11 @@ const ( height = 400 spacing = 25 logo_path = "/usr/share/pixmaps/phyOS-logo-128x128.png" + + info_message = `OPTIONS Tab: Customize themes, wallpaper and more +ANIMATIONS Tab: Set up animations and picom related options +Check out 'man phyos' for available scripts +` ) func imageNew(path string) *gtk.Image { @@ -64,7 +69,7 @@ func main() { if err != nil { log.Fatal("Unable to create notebook:", err) } - win := windowNew("phy") + win := windowNew("physettings") win.Add(nb) nb.SetHExpand(true) nb.SetVExpand(true) @@ -72,9 +77,16 @@ func main() { logo := imageNew(logo_path) box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 15) logo.SetHAlign(gtk.ALIGN_CENTER) + + lblTitle, _ := gtk.LabelNew("") + lblTitle.SetMarginBottom(50) + lblTitle.SetMarkup("phyOS Settings App") + lblInfo, _ := gtk.LabelNew(info_message) box.SetMarginStart(spacing) box.SetMarginTop(spacing) box.Add(logo) + box.Add(lblTitle) + box.Add(lblInfo) // Add a child widget and tab label to the notebook so it renders. diff --git a/settings/options.go b/settings/options.go index 04ebffd..3cc03a8 100644 --- a/settings/options.go +++ b/settings/options.go @@ -4,7 +4,7 @@ import ( "fmt" "log" "os/exec" - u "physettings/utils" + u "github.com/FT-Labs/physettings-gtk/utils" "github.com/gotk3/gotk3/gtk" ) @@ -52,10 +52,18 @@ func SetupOptionsTab() *gtk.Box { comboBoxAddEntries(u.PowerMenuTypes, cbPowermenuType.ComboBox) comboBoxAddEntries(u.PowerMenuStyles, cbPowermenuStyle.ComboBox) - cbRofiColor.ComboBox.Connect("popdown", func() { + cbRofiColor.ComboBox.Connect("changed", func() { u.SetRofiColor(cbRofiColor.ComboBox.GetActiveText()) }) + cbPowermenuType.ComboBox.Connect("changed", func() { + u.SetAttribute(u.POWERMENU_TYPE, cbPowermenuType.ComboBox.GetActiveText()) + }) + + cbPowermenuStyle.ComboBox.Connect("changed", func() { + u.SetAttribute(u.POWERMENU_STYLE, cbPowermenuStyle.ComboBox.GetActiveText()) + }) + chkAsk, _ := gtk.CheckButtonNewWithLabel("Confirm on Shutdown") if u.Attrs[u.POWERMENU_CONFIRM] == "true" { diff --git a/utils/utils.go b/utils/utils.go index 05bdca6..cbc6af1 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -116,7 +116,7 @@ func SetAttribute(attribute, value string) error { func SetRofiColor(c string) { cmd := fmt.Sprintf("ln -sf /usr/share/phyos/config/rofi/colors/%s.rasi ~/.config/rofi/colors.rasi", c) - exec.Command("/bin/bash", "-c", cmd).Start() + exec.Command("/bin/bash", "-c", cmd).Run() } func RunScript(c string) error {