10 Commits

Author SHA1 Message Date
Adrian Zürcher
e480141e89 fix workflow take 2 only linux
All checks were successful
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m23s
2026-01-18 17:04:52 +01:00
Adrian Zürcher
e1ae34a336 update workflow
Some checks failed
Build Slideshow App / build (amd64, , linux) (push) Has been cancelled
Build Slideshow App / build (amd64, .exe, windows) (push) Has been cancelled
Build Slideshow App / build (arm, 7, , linux) (push) Has been cancelled
Build Slideshow App / build (arm64, , linux) (push) Has been cancelled
2026-01-18 15:27:39 +01:00
Adrian Zürcher
3aac950b9c add new debian install workflow for linux
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m49s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m8s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m53s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m51s
2026-01-17 22:42:16 +01:00
Adrian Zürcher
96bfcb7d0e add new set function 2026-01-17 22:41:54 +01:00
Adrian Zürcher
64744e218a add feature check if ip is active 2026-01-17 22:41:42 +01:00
Adrian Zürcher
7d3db6b485 remove schedule.json file 2026-01-17 22:41:21 +01:00
Adrian Zürcher
9cde384a36 add browser open function 2026-01-17 22:39:50 +01:00
f9a92e4e4a Fix appname artifact
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m56s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m2s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m42s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m48s
2026-01-17 18:12:49 +01:00
40b13a0661 Change upload v4 to v3
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m2s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m16s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m50s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m45s
2026-01-17 15:10:58 +01:00
Adrian Zürcher
ff473d0e8d since v6 is not supported downgrade to v4
Some checks failed
Build Slideshow App / build (amd64, .exe, windows) (push) Failing after 2m36s
Build Slideshow App / build (amd64, , linux) (push) Failing after 2m39s
Build Slideshow App / build (arm, 6, , linux) (push) Failing after 1m59s
Build Slideshow App / build (arm64, , linux) (push) Failing after 1m58s
2026-01-17 00:27:16 +01:00
7 changed files with 306 additions and 112 deletions

View File

@@ -15,24 +15,24 @@ jobs:
strategy: strategy:
matrix: matrix:
include: include:
- os: windows #- os: windows
arch: amd64 # arch: amd64
ext: .exe # ext: .exe
- os: linux #- os: linux
arch: amd64 # arch: amd64
ext: "" # ext: ""
- os: linux - os: linux
arch: arm64 arch: arm64
ext: "" ext: ""
- os: linux #- os: linux
arch: arm # arch: arm
arm_version: 6 # arm_version: 7
ext: "" # ext: ""
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v6 uses: actions/checkout@v3
- name: Ensure latest Go is installed in /data/go - name: Ensure latest Go is installed in /data/go
run: | run: |
@@ -76,18 +76,114 @@ jobs:
OUTPUT="${APP_NAME}" OUTPUT="${APP_NAME}"
if [ -n "${{ matrix.arm_version }}" ]; then if [ -n "${{ matrix.arm_version }}" ]; then
OUTPUT="${OUTPUT}v${{ matrix.arm_version }}"
export GOARM=${{ matrix.arm_version }} export GOARM=${{ matrix.arm_version }}
fi fi
OUTPUT="${OUTPUT}${{ matrix.ext }}" OUTPUT="${OUTPUT}${{ matrix.ext }}"
echo "Building $OUTPUT" echo "Building $OUTPUT"
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT" GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
shell: bash shell: bash
- name: Upload artifact - name: Create Debian Package
uses: actions/upload-artifact@v6 if: matrix.os == 'linux'
run: |
# 1. Setup Variables
VERSION=${GITHUB_REF_NAME#v} # Extracts 1.0.0 from v1.0.0
ARCH=${{ matrix.arch }}
if [ "$ARCH" == "arm" ]; then ARCH="armhf"; fi
PKG_NAME="slideshowapp"
BUILD_DIR="${PKG_NAME}_${VERSION}_${ARCH}"
# 2. Create Directory Structure
mkdir -p $BUILD_DIR/usr/bin
mkdir -p $BUILD_DIR/usr/share/$PKG_NAME
mkdir -p $BUILD_DIR/etc/systemd/system
mkdir -p $BUILD_DIR/DEBIAN
# 3. Copy Files
cp ${APP_NAME} $BUILD_DIR/usr/bin/$PKG_NAME
cp -r ./web $BUILD_DIR/usr/share/$PKG_NAME/
chmod +x $BUILD_DIR/usr/bin/$PKG_NAME
# 4. Handle .env (Copy as a .template so it doesn't overwrite existing ones)
if [ -f ".env" ]; then
cp .env $BUILD_DIR/usr/share/$PKG_NAME/.env.template
else
echo "PORT=8080" > $BUILD_DIR/usr/share/$PKG_NAME/.env.template
fi
# 5. Create the systemd Service File
cat <<EOF > $BUILD_DIR/etc/systemd/system/$PKG_NAME.service
[Unit]
Description=Slideshow Application Service
After=graphical.target
[Service]
Type=simple
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/youruser/.Xauthority
ExecStart=/usr/bin/$PKG_NAME
WorkingDirectory=/usr/share/$PKG_NAME
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
# 6. Create Control File
cat <<EOF > $BUILD_DIR/DEBIAN/control
Package: $PKG_NAME
Version: $VERSION
Section: utils
Priority: optional
Architecture: $ARCH
Maintainer: Your Name <you@example.com>
Description: Slideshow Application
EOF
# 7. Optional: Add post-install script to enable service automatically
echo "create service"
cat <<EOF > $BUILD_DIR/DEBIAN/postinst
#!/bin/sh
# Check if .env exists in the target share folder
if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
echo "Creating new .env from template..."
cp /usr/share/$PKG_NAME/.env.template /usr/share/$PKG_NAME/.env
else
echo ".env already exists, skipping template copy to preserve settings."
fi
echo "reload"
systemctl daemon-reload
echo "enable service"
systemctl enable $PKG_NAME.service
echo "start service"
systemctl start $PKG_NAME.service
EOF
chmod 555 $BUILD_DIR/DEBIAN/postinst
# 8. Build .deb
dpkg-deb --build $BUILD_DIR
shell: bash
# Upload for Windows (Binary + Web folder)
- name: Upload Windows Artifact
if: matrix.os == 'windows'
uses: actions/upload-artifact@v3
with: with:
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }} name: ${{ env.APP_NAME }}-windows
path: | path: |
${{ env.APP_NAME }}.exe
./web ./web
${APP_NAME}${{ matrix.ext }}
# Upload for Linux (Binary + .deb)
- name: Upload Linux Artifact
if: matrix.os == 'linux'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-linux-${{ matrix.arch }}
path: |
${{ env.APP_NAME }}
*.deb

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
images/ images/
slideshowApp slideshowApp
schedule.json

4
env/enviroment.go vendored
View File

@@ -28,6 +28,10 @@ func (key EnvKey) GetValue() string {
return os.Getenv(string(key)) return os.Getenv(string(key))
} }
func (key EnvKey) SetValue(value string) {
os.Setenv(string(key), value)
}
func (key EnvKey) GetBoolValue() bool { func (key EnvKey) GetBoolValue() bool {
value := strings.ToLower(os.Getenv(string(key))) value := strings.ToLower(os.Getenv(string(key)))
return value == "true" || value == "1" return value == "true" || value == "1"

View File

@@ -5,30 +5,32 @@ import (
"net" "net"
"net/http" "net/http"
"slideshowApp/env" "slideshowApp/env"
"strings"
) )
// Helper to get the local network IP address // Helper to get the local network IP address
func getLocalIP() string { func GetLocalIP() string {
if env.Host.GetValue() != "0.0.0.0" && env.Host.GetValue() != "localhost" { if env.Host.GetValue() != "0.0.0.0" && env.Host.GetValue() != "localhost" {
return env.Host.GetValue() return env.Host.GetValue()
} }
addrs, err := net.InterfaceAddrs() if ip := getActiveIP(); ip != "" {
return ip
}
return "localhost"
}
func getActiveIP() string {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil { if err != nil {
return "localhost" return ""
} }
for _, address := range addrs { defer conn.Close()
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil { addr := conn.LocalAddr()
if env.Env.GetValue() == "development" && !strings.Contains(ipnet.IP.String(), "192.168") { if udpAddr, ok := addr.(*net.UDPAddr); ok {
continue return udpAddr.IP.String()
} }
return ipnet.IP.String() return ""
}
}
}
return "localhost"
} }
func InfoHandler(w http.ResponseWriter, r *http.Request) { func InfoHandler(w http.ResponseWriter, r *http.Request) {
@@ -43,7 +45,7 @@ func InfoHandler(w http.ResponseWriter, r *http.Request) {
} }
data := map[string]string{ data := map[string]string{
"ip": getLocalIP(), "ip": GetLocalIP(),
"port": port, "port": port,
"speed": speed, "speed": speed,
} }

13
main.go
View File

@@ -7,6 +7,8 @@ import (
"os" "os"
"slideshowApp/env" "slideshowApp/env"
"slideshowApp/handlers" "slideshowApp/handlers"
"slideshowApp/utils"
"time"
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )
@@ -23,11 +25,14 @@ func main() {
if _, err := os.Stat(uploadFolder); err != nil { if _, err := os.Stat(uploadFolder); err != nil {
fmt.Println("upload folder for images not found: ", uploadFolder) fmt.Println("upload folder for images not found: ", uploadFolder)
fmt.Println("use fallback") fmt.Println("use fallback folder")
uploadFolder = "./images" uploadFolder = "./images"
env.PhotoDir.SetValue(uploadFolder)
} }
fmt.Println("upload folder for images: ", uploadFolder) fmt.Println("upload folder for images: ", uploadFolder)
r.PathPrefix("/uploads/").Handler(http.StripPrefix("/uploads/", http.FileServer(http.Dir(uploadFolder)))) r.PathPrefix("/uploads/").Handler(http.StripPrefix("/uploads/", http.FileServer(http.Dir(uploadFolder))))
r.HandleFunc("/api/images", handlers.ListFilesHandler).Methods("GET") r.HandleFunc("/api/images", handlers.ListFilesHandler).Methods("GET")
r.HandleFunc("/ws", handlers.Websocket) r.HandleFunc("/ws", handlers.Websocket)
@@ -54,6 +59,12 @@ func main() {
host := env.Host.GetValue() host := env.Host.GetValue()
port := env.Port.GetValue() port := env.Port.GetValue()
url := fmt.Sprintf("%s:%s", host, port) url := fmt.Sprintf("%s:%s", host, port)
go func() {
time.Sleep(3 * time.Second)
if err := utils.OpenBrowser(fmt.Sprintf("%s:%s/slideshow", handlers.GetLocalIP(), port)); err != nil {
fmt.Println(err)
}
}()
fmt.Println("Server running at", url) fmt.Println("Server running at", url)
log.Fatal(http.ListenAndServe(url, r)) log.Fatal(http.ListenAndServe(url, r))
} }

View File

@@ -1 +0,0 @@
{"Friday_active":false,"Friday_end":"07:38","Friday_start":"07:00","Monday_active":false,"Monday_end":"22:00","Monday_start":"08:00","Saturday_active":false,"Saturday_end":"22:00","Saturday_start":"08:00","Sunday_active":false,"Sunday_end":"22:00","Sunday_start":"08:00","Thursday_active":false,"Thursday_end":"22:00","Thursday_start":"08:00","Tuesday_active":false,"Tuesday_end":"22:00","Tuesday_start":"08:00","Wednesday_active":false,"Wednesday_end":"22:00","Wednesday_start":"08:00"}

81
utils/utils.go Normal file
View File

@@ -0,0 +1,81 @@
package utils
import (
"fmt"
"os"
"os/exec"
"runtime"
)
func OpenBrowser(url string) error {
var commands [][]string
switch runtime.GOOS {
case "windows":
commands = [][]string{
// Chrome (most common)
{`C:\Program Files\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
{`C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
// Edge (default on modern Windows)
{`C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`, "--kiosk", url},
{`C:\Program Files\Microsoft\Edge\Application\msedge.exe`, "--kiosk", url},
// Firefox (no true kiosk, but fullscreen)
{`C:\Program Files\Mozilla Firefox\firefox.exe`, "--kiosk", url},
{`C:\Program Files (x86)\Mozilla Firefox\firefox.exe`, "--kiosk", url},
// System default browser (always works)
{"rundll32", "url.dll,FileProtocolHandler", url},
}
case "darwin":
commands = [][]string{
// Chrome
{"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--kiosk", url},
// Edge
{"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "--kiosk", url},
// Firefox
{"/Applications/Firefox.app/Contents/MacOS/firefox", "--kiosk", url},
// Safari (no kiosk flag, opens normally)
{"open", "-a", "Safari", url},
// System default browser
{"open", url},
}
default: // Linux
if os.Getenv("DISPLAY") == "" &&
os.Getenv("WAYLAND_DISPLAY") == "" &&
os.Getenv("XDG_SESSION_TYPE") != "wayland" {
return fmt.Errorf("os is running in headless mode; do not start browser")
}
commands = [][]string{
// Chromium / Chrome
{"chromium-browser", "--kiosk", url},
{"chromium", "--kiosk", url},
{"google-chrome", "--kiosk", url},
// Firefox
{"firefox", "--kiosk", url},
// System default browser (best universal fallback)
{"xdg-open", url},
}
}
for _, cmd := range commands {
execCmd := exec.Command(cmd[0], cmd[1:]...)
if err := execCmd.Start(); err == nil {
return nil
} else {
return err
}
}
return fmt.Errorf("could not open browser")
}