diff --git a/.drone.yml b/.drone.yml
index 4f0b242..16e0247 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -27,7 +27,7 @@ steps:
- apk --no-cache add alsa-lib-dev build-base git pkgconf
- go get -v -d
- go vet -v
- - go build -v -ldflags '-w -X main.Version=${DRONE_BRANCH}-${DRONE_COMMIT} -X main.build=${DRONE_BUILD_NUMBER}' -o deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
+ - go build -tags pulse -ldflags '-w -X main.Version=${DRONE_BRANCH}-${DRONE_COMMIT} -X main.build=${DRONE_BUILD_NUMBER}' -o deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
- ln deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} reveil
when:
event:
@@ -40,7 +40,7 @@ steps:
- apk --no-cache add alsa-lib-dev build-base git pkgconf
- go get -v -d
- go vet -v
- - go build -v -ldflags '-w -X main.Version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -o deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7
+ - go build -tags pulse -ldflags '-w -X main.Version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -o deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7
- ln deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7 reveil
when:
event:
@@ -50,7 +50,7 @@ steps:
image: golang:1-alpine
commands:
- apk --no-cache add alsa-lib-dev build-base git pkgconf
- - go build -v -tags netgo -ldflags '-w -X main.Version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -o deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}hf
+ - go build -tags pulse,netgo -ldflags '-w -X main.Version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -o deploy/reveil-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}hf
environment:
CGO_ENABLED: 0
GOARM: 6
diff --git a/Dockerfile b/Dockerfile
index d420e0c..3a2416b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,7 +15,7 @@ RUN apk --no-cache add git go-bindata
COPY . /go/src/git.nemunai.re/nemunaire/reveil
COPY --from=nodebuild /ui/build /go/src/git.nemunai.re/nemunaire/reveil/ui/build
WORKDIR /go/src/git.nemunai.re/nemunaire/reveil
-RUN go get -v && go generate -v && go build -v -ldflags="-s -w"
+RUN go get -v && go generate -v && go build -tags pulse -ldflags="-s -w"
FROM alpine:3.20
diff --git a/model/settings.go b/model/settings.go
index 7c1cb51..7d1471e 100644
--- a/model/settings.go
+++ b/model/settings.go
@@ -13,6 +13,7 @@ type Settings struct {
WeatherDelay time.Duration `json:"weather_delay"`
WeatherAction string `json:"weather_action"`
MaxRunTime time.Duration `json:"max_run_time"`
+ MaxVolume uint16 `json:"max_volume"`
}
// ExistsSettings checks if the settings file can by found at the given path.
diff --git a/player/player.go b/player/player.go
index c12e552..dcee619 100644
--- a/player/player.go
+++ b/player/player.go
@@ -21,6 +21,7 @@ var CommonPlayer *Player
type Player struct {
Playlist []string
MaxRunTime time.Duration
+ MaxVolume uint16
Stopper chan bool
currentCmd *exec.Cmd
currentCmdCh chan bool
@@ -77,6 +78,7 @@ func NewPlayer(cfg *config.Config, routines []reveil.Identifier) (*Player, error
Stopper: make(chan bool, 1),
currentCmdCh: make(chan bool, 1),
MaxRunTime: settings.MaxRunTime * time.Minute,
+ MaxVolume: uint16(settings.MaxVolume),
weatherTime: settings.WeatherDelay * time.Minute,
weatherAction: wact,
claironTime: settings.GongInterval * time.Minute,
@@ -136,7 +138,7 @@ func (p *Player) launchAction(cfg *config.Config, a *reveil.Action) (err error)
}
func (p *Player) playFile(filepath string) (err error) {
- p.currentCmd = exec.Command("paplay", filepath)
+ p.currentCmd = exec.Command(playCommand, filepath)
if err = p.currentCmd.Start(); err != nil {
log.Println("Running paplay err: ", err.Error())
p.currentCmdCh <- true
@@ -270,7 +272,11 @@ func (p *Player) NextTrack() {
}
func (p *Player) SetVolume(volume uint16) error {
- cmd := exec.Command("amixer", "-D", "pulse", "set", "Master", fmt.Sprintf("%d", volume))
+ if p.MaxVolume == 0 {
+ p.MaxVolume = 65535
+ }
+
+ cmd := exec.Command("amixer", "-D", mixerCard, "set", mixerName, fmt.Sprintf("%d", uint32(volume)*uint32(p.MaxVolume)/65535))
return cmd.Run()
}
diff --git a/player/player_pulse.go b/player/player_pulse.go
new file mode 100644
index 0000000..d09fa40
--- /dev/null
+++ b/player/player_pulse.go
@@ -0,0 +1,9 @@
+//go:build pulse
+
+package player
+
+const (
+ playCommand = "paplay"
+ mixerCard = "pulse"
+ mixerName = "Master"
+)
diff --git a/ui/routes.go b/ui/routes.go
index cd554a5..ba5e528 100644
--- a/ui/routes.go
+++ b/ui/routes.go
@@ -58,8 +58,10 @@ func DeclareRoutes(router *gin.Engine, cfg *config.Config) {
router.GET("/.svelte-kit/*_", serveOrReverse("", cfg))
router.GET("/node_modules/*_", serveOrReverse("", cfg))
router.GET("/@vite/*_", serveOrReverse("", cfg))
+ router.GET("/@id/*_", serveOrReverse("", cfg))
router.GET("/@fs/*_", serveOrReverse("", cfg))
router.GET("/src/*_", serveOrReverse("", cfg))
+ router.GET("/home/*_", serveOrReverse("", cfg))
}
router.GET("/", serveOrReverse("", cfg))
diff --git a/ui/src/lib/settings.js b/ui/src/lib/settings.js
index cb05812..29f11c6 100644
--- a/ui/src/lib/settings.js
+++ b/ui/src/lib/settings.js
@@ -5,12 +5,13 @@ export class Settings {
}
}
- update({ language, gong_interval, weather_delay, weather_action, max_run_time }) {
+ update({ language, gong_interval, weather_delay, weather_action, max_run_time, max_volume }) {
this.language = language;
this.gong_interval = gong_interval;
this.weather_delay = weather_delay;
this.weather_action = weather_action;
this.max_run_time = max_run_time;
+ this.max_volume = max_volume;
}
async save() {
diff --git a/ui/src/routes/settings/+page.svelte b/ui/src/routes/settings/+page.svelte
index 4bfb8c0..f43e57b 100644
--- a/ui/src/routes/settings/+page.svelte
+++ b/ui/src/routes/settings/+page.svelte
@@ -116,6 +116,20 @@
min
+
+
+
+
+
+
+
{/await}
diff --git a/ui/vite.config.js b/ui/vite.config.js
index 8747050..9904c11 100644
--- a/ui/vite.config.js
+++ b/ui/vite.config.js
@@ -2,6 +2,12 @@ import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
+ server: {
+ hmr: {
+ port: 10000
+ }
+ },
+
plugins: [sveltekit()]
};