Compare commits
3 Commits
ef3aa5f89e
...
11163f059b
Author | SHA1 | Date | |
---|---|---|---|
11163f059b | |||
41f8092419 | |||
6f495f4fe1 |
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
9
player/player_pulse.go
Normal file
9
player/player_pulse.go
Normal file
@ -0,0 +1,9 @@
|
||||
//go:build pulse
|
||||
|
||||
package player
|
||||
|
||||
const (
|
||||
playCommand = "paplay"
|
||||
mixerCard = "pulse"
|
||||
mixerName = "Master"
|
||||
)
|
@ -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))
|
||||
|
@ -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() {
|
||||
|
@ -116,6 +116,20 @@
|
||||
<InputGroupText>min</InputGroupText>
|
||||
</InputGroup>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<Label for="maxVolume">Volume maximum</Label>
|
||||
<InputGroup>
|
||||
<Input
|
||||
type="range"
|
||||
id="maxVolume"
|
||||
min="0"
|
||||
max="65535"
|
||||
bind:value={settings.max_volume}
|
||||
on:input={submitSettings}
|
||||
/>
|
||||
</InputGroup>
|
||||
</FormGroup>
|
||||
{/await}
|
||||
</Form>
|
||||
</Container>
|
||||
|
@ -2,6 +2,12 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
||||
|
||||
/** @type {import('vite').UserConfig} */
|
||||
const config = {
|
||||
server: {
|
||||
hmr: {
|
||||
port: 10000
|
||||
}
|
||||
},
|
||||
|
||||
plugins: [sveltekit()]
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user