5 Commits

Author SHA1 Message Date
Adrian Zürcher
46a56e130f change appname constant to variable
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m58s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m16s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m54s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m56s
2026-02-03 11:28:08 +01:00
Adrian Zürcher
aa900d5e3b fix enviroment bug
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m11s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m25s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 2m16s
Build Slideshow App / build (arm64, , linux) (push) Successful in 2m12s
2026-02-03 09:19:06 +01:00
Adrian Zürcher
91cb3a48f8 fix active ip for all os 2026-02-03 09:18:55 +01:00
Adrian Zürcher
e05c3a06ae some changes
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m0s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m20s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m57s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m58s
2026-01-31 20:37:03 +01:00
Adrian Zürcher
5e551b4eaf add content-type header and error response
All checks were successful
Build Slideshow App / build (amd64, , linux) (push) Successful in 1m37s
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m19s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m27s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m28s
2026-01-31 20:14:54 +01:00
5 changed files with 40 additions and 28 deletions

View File

@@ -92,7 +92,7 @@ jobs:
ARCH=${{ matrix.arch }} ARCH=${{ matrix.arch }}
if [ "$ARCH" == "arm" ]; then ARCH="armhf"; fi if [ "$ARCH" == "arm" ]; then ARCH="armhf"; fi
PKG_NAME="slideshowapp" PKG_NAME="${APP_NAME}"
BUILD_DIR="${PKG_NAME}_${VERSION}_${ARCH}" BUILD_DIR="${PKG_NAME}_${VERSION}_${ARCH}"
# 2. Create Directory Structure # 2. Create Directory Structure
@@ -120,7 +120,7 @@ jobs:
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Name=Slideshow App Name=Slideshow App
Exec=sh -c 'i=0; while [ $i -lt 30 ]; do if [ "$(ls -A /media/$USER 2>/dev/null)" ] && ping -c 1 -W 1 8.8.8.8 >/dev/null 2>&1; then break; fi; i=$((i+1)); sleep 1; done; cd /usr/share/slideshowapp && /usr/bin/slideshowapp' Exec=sh -c 'i=0; while [ $i -lt 30 ]; do if [ "$(ls -A /media/$USER 2>/dev/null)" ] && ping -c 1 -W 1 8.8.8.8 >/dev/null 2>&1; then break; fi; i=$((i+1)); sleep 1; done; cd /usr/share/$PKG_NAME && /usr/bin/$PKG_NAME'
Terminal=false Terminal=false
EOF EOF
@@ -151,17 +151,17 @@ jobs:
USER_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6) USER_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
echo "Setting permissions for /usr/share/slideshowapp..." echo "Setting permissions for /usr/share/$PKG_NAME..."
chown -R "$REAL_USER:$REAL_USER" /usr/share/slideshowapp chown -R "$REAL_USER:$REAL_USER" /usr/share/$PKG_NAME
chmod -R 755 /usr/share/slideshowapp chmod -R 755 /usr/share/$PKG_NAME
echo "Post-install: Target user is $REAL_USER" echo "Post-install: Target user is $REAL_USER"
echo "Post-install: Target home is $USER_HOME" echo "Post-install: Target home is $USER_HOME"
# 2. Setup .env from template # 2. Setup .env from template
if [ ! -f "/usr/share/slideshowapp/.env" ]; then if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
echo "Creating .env from template..." echo "Creating .env from template..."
cp /usr/share/slideshowapp/env.template /usr/share/slideshowapp/.env || true cp /usr/share/$PKG_NAME/env.template /usr/share/$PKG_NAME/.env || true
fi fi
# 3. Setup Autostart # 3. Setup Autostart
@@ -171,11 +171,11 @@ jobs:
if [ -d "$USER_HOME" ]; then if [ -d "$USER_HOME" ]; then
echo "Creating autostart directory at $AUTOSTART_DIR" echo "Creating autostart directory at $AUTOSTART_DIR"
mkdir -p "$AUTOSTART_DIR" mkdir -p "$AUTOSTART_DIR"
cp /usr/share/slideshowapp/setup/slideshowapp.desktop "$AUTOSTART_DIR/" cp /usr/share/$PKG_NAME/setup/$PKG_NAME.desktop "$AUTOSTART_DIR/"
# Critical: Change ownership of the folder and the file # Critical: Change ownership of the folder and the file
chown -R "$REAL_USER:$REAL_USER" "$USER_HOME/.config" chown -R "$REAL_USER:$REAL_USER" "$USER_HOME/.config"
chmod 644 "$AUTOSTART_DIR/slideshowapp.desktop" chmod 644 "$AUTOSTART_DIR/$PKG_NAME.desktop"
else else
echo "ERROR: Home directory $USER_HOME not found. Autostart not configured." echo "ERROR: Home directory $USER_HOME not found. Autostart not configured."
fi fi

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@ images/
slideshowApp slideshowApp
schedule.json schedule.json
*.log *.log
*.exe

8
env/enviroment.go vendored
View File

@@ -26,7 +26,13 @@ func Load(path string) error {
} }
func (key EnvKey) GetValue() string { func (key EnvKey) GetValue() string {
return os.Getenv(string(key)) keyStr := string(key)
value := os.Getenv(keyStr)
if key == Port && value == "" {
value = "8080"
}
return value
} }
func (key EnvKey) SetValue(value string) { func (key EnvKey) SetValue(value string) {

View File

@@ -20,34 +20,39 @@ func GetLocalIP() string {
} }
func getActiveIP() string { func getActiveIP() string {
conn, err := net.Dial("udp", "8.8.8.8:80") addrs, err := net.InterfaceAddrs()
if err != nil { if err != nil {
return "" return ""
} }
defer conn.Close()
addr := conn.LocalAddr() for _, address := range addrs {
if udpAddr, ok := addr.(*net.UDPAddr); ok { if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
return udpAddr.IP.String()
if ipnet.IP.To4() != nil {
ipStr := ipnet.IP.String()
if ipnet.IP.IsLinkLocalUnicast() {
continue
}
return ipStr
}
}
} }
return "" return ""
} }
func InfoHandler(w http.ResponseWriter, r *http.Request) { func InfoHandler(w http.ResponseWriter, r *http.Request) {
port := env.Port.GetValue() w.Header().Set("Content-Type", "application/json")
if port == "" {
port = "8080"
}
speed := env.IntervalDefault.GetValue()
if speed == "" {
speed = "10"
}
data := map[string]string{ data := map[string]string{
"ip": GetLocalIP(), "ip": GetLocalIP(),
"port": port, "port": env.Port.GetValue(),
"speed": GetInterval(), "speed": GetInterval(),
} }
json.NewEncoder(w).Encode(data) err := json.NewEncoder(w).Encode(data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} }