From 23425df60484c1a6a543d578bc77ec9e302bee21 Mon Sep 17 00:00:00 2001 From: DaanSelen Date: Fri, 9 Jan 2026 17:01:49 +0100 Subject: [PATCH] chore: qol update --- install.sh | 9 +++++++ service-files/presentation.service | 15 ++++++++++++ src/action.go | 10 ++++---- src/draw.go | 38 ++++++------------------------ src/rpi-list.go | 9 +++---- 5 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 install.sh create mode 100644 service-files/presentation.service diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..3f3173a --- /dev/null +++ b/install.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +runtime_id=$(id -u) +if [[ "$runtime_id" -ne 0 ]]; then + echo "Not running as root, please run as root." + exit 1 +fi + +apt-get -y install vlc libreoffice-impress \ No newline at end of file diff --git a/service-files/presentation.service b/service-files/presentation.service new file mode 100644 index 0000000..8291374 --- /dev/null +++ b/service-files/presentation.service @@ -0,0 +1,15 @@ +[Unit] +Description="Systemec Akarton Raspberry Pi Uploader Program (SARPUS) " +After=graphical.target + +[Service] +Type=simple +Environment=DISPLAY=:0 +ExecStartPre=/usr/bin/sleep 5 +ExecStart=/usr/bin/libreoffice --impress --show /home/systemec/Downloads/test_pres.pptx --norestore +ExecStop=/usr/bin/killall libreoffice +Restart=on-failure +RestartSec=2 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/src/action.go b/src/action.go index 02117ac..186202a 100644 --- a/src/action.go +++ b/src/action.go @@ -8,19 +8,19 @@ import ( "golang.org/x/crypto/ssh" ) -func translateRaspiName(targetName string) (string, string) { +func translateRaspiName(targetName string) (string, string, string, string) { for _, raspiObj := range raspiList { if raspiObj[0] == targetName { // Found! - return raspiObj[1], raspiObj[2] + return raspiObj[1], raspiObj[2], raspiObj[3], raspiObj[4] } } - return "", "" + return "", "", "", "" } -func verifyCred(username, password, targetName string) bool { - hostname, port := translateRaspiName(targetName) +func verifyCred(targetName string) bool { + hostname, port, username, password := translateRaspiName(targetName) log.Println("Connecting to:", hostname, port) config := &ssh.ClientConfig{ diff --git a/src/draw.go b/src/draw.go index 885e7ee..2f86f9d 100644 --- a/src/draw.go +++ b/src/draw.go @@ -30,6 +30,10 @@ func flashRed(btnPtr *widget.Button) { }, false) } +func drawVerifyProcess() { + +} + func drawSeparator(trailNewLine bool) *fyne.Container { emptyLabel := widget.NewLabel("") // Give it some space at the bottom with an empty line separatorLine := canvas.NewLine(color.Gray{Y: 128}) @@ -113,47 +117,19 @@ func drawTargetSection(raspiNames []string, raspiTarget *string) *fyne.Container refreshButtons(verifyBtn) }) - // Right side authentication - userLabel := widget.NewLabel("Username") - passLabel := widget.NewLabel("Password") - - userEntry := widget.NewEntry() - userEntry.SetPlaceHolder("") - - passEntry := widget.NewPasswordEntry() - passEntry.SetPlaceHolder("") - - expander := canvas.NewRectangle(color.Transparent) - expander.SetMinSize(fyne.NewSize(150, 0)) - targetAuth := container.NewVBox( - container.NewGridWithColumns(2, userLabel, expander), - userEntry, - container.NewGridWithColumns(2, passLabel, expander), - passEntry, - ) - - divider := canvas.NewRectangle(color.Transparent) - divider.SetMinSize(fyne.NewSize(250, 0)) - selecCol := container.NewVBox( actionText, piSelection, ) - targetRow := container.NewHBox( - selecCol, - divider, - targetAuth, - ) - var credOK bool - verifyBtn = widget.NewButton("Verify Credentials", func() { + verifyBtn = widget.NewButton("Check Connection", func() { verifyBtn.Importance = widget.HighImportance refreshButtons(verifyBtn) log.Println("Verifying credentials...") go func() { - credOK = verifyCred(userEntry.Text, passEntry.Text, *raspiTarget) + credOK = verifyCred(*raspiTarget) if credOK { // Must update UI on main thread @@ -172,7 +148,7 @@ func drawTargetSection(raspiNames []string, raspiTarget *string) *fyne.Container ) wholeCol := container.NewVBox( - targetRow, + selecCol, widget.NewLabel(""), verifyWide, ) diff --git a/src/rpi-list.go b/src/rpi-list.go index bc760ce..3afbfe7 100644 --- a/src/rpi-list.go +++ b/src/rpi-list.go @@ -5,10 +5,11 @@ var ( // 0 Raspberry Pi Name // 1 Raspberry Pi IP-Adress // 2 Raspberry Pi SSH-port + // 3 Raspberry Pi SSH Username + // 4 Raspberry Pi SSH Password raspiList [][]string = [][]string{ - {"Kantine Pi", "172.16.64.228", "22"}, - {"Productie Pi", "172.16.64.229", "22"}, - {"Sales Pi", "", ""}, - {"MyTempHost", "192.168.178.20", "22"}, + {"Kantine Pi", "172.16.64.228", "22", "systemec", ""}, + {"Productie Pi", "172.16.64.229", "22", "", ""}, + {"Sales Pi", "", "", "", ""}, } )