Skip to content

Commit

Permalink
Merge branch 'develop' into steam-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Jul 19, 2024
2 parents c05a68b + 8caf781 commit 5b73007
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 99 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Color temperature control for native SteamVR headsets (e.g. Vive (Pro), Valve Index, Bigscreen Beyond)
- Color temperature control to the current brightness automations.
- Sunset/Sunrise based automations for brightness and color temperature.
- Option for the shutdown sequence being triggered by being alone to only trigger while the sleep mode is enabled.
- Option for audio volume automations to apply on start.

### Changed

Expand All @@ -23,10 +25,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Option for the brightness automations based on sleep mode to run on SteamVR launch. This now happens automatically when a HMD is connected.

## [1.13.3]

### Fixed

- Battery level based power automations turning off devices above the threshold
- Certain types of selection in input fields (e.g. Ctrl+A) being blocked

### Changed
- Window titlebar icons

## [1.13.2]

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions src-ui/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ import {
SettingsBrightnessCctViewComponent,
} from './views/dashboard-view/views/settings-brightness-cct-view/settings-brightness-cct-view.component';
import { CCTInputSettingComponent } from './components/cct-input-setting/cct-input-setting.component';
import { BrightnessAdvancedModeToggleComponent } from './components/brightness-advanced-mode-toggle/brightness-advanced-mode-toggle.component';

[
localeEN,
Expand Down Expand Up @@ -371,6 +372,7 @@ export function createTranslateLoader(http: HttpClient) {
CCTInputSettingComponent,
CCTControlModalComponent,
SettingsBrightnessCctViewComponent,
BrightnessAdvancedModeToggleComponent,
],
exports: [SelectBoxComponent],
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="advanced-toggle">
<div class="advanced-toggle-clickable" (click)="toggleAdvancedMode()">
<label class="switch-toggle">
<input type="checkbox" [checked]="advancedMode" disabled />
<span class="switch-toggle-slider"></span>
</label>
<span @hshrink *ngIf="!advancedMode" translate>brightness-automations.mode.simple</span>
<span @hshrink *ngIf="advancedMode" translate>brightness-automations.mode.advanced</span>
</div>
<i class="material-icons-round help-icon" (click)="showModeInfoModal()">help</i>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.advanced-toggle {
font-size: 0.6em;
display: flex;
flex-direction: row;
align-items: center;
background: var(--color-surface-0);
border-radius: var(--surface-border-radius);

&-clickable {
display: flex;
flex-direction: row;
align-items: center;
padding: 0.5em 0.75em;
transition: all 0.15s ease;
cursor: pointer;

&:active {
opacity: 0.75;
}
}

.help-icon {
font-size: 1.2em;
color: var(--color-text-3);
transition: all 0.15s ease;
line-height: 0;
padding: 0.5em 0.75em 0.5em 0;

&:hover {
cursor: pointer;
color: var(--color-text-2);
}

&:active {
color: var(--color-text-3);
}
}

span {
white-space: nowrap;
}

label {
margin-right: 0.5em;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Component } from '@angular/core';
import {
ConfirmModalComponent,
ConfirmModalInputModel,
ConfirmModalOutputModel,
} from '../confirm-modal/confirm-modal.component';
import { BrightnessAutomationsConfig } from '../../models/automations';
import { ModalService } from '../../services/modal.service';
import { AutomationConfigService } from '../../services/automation-config.service';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { hshrink } from '../../utils/animations';

@Component({
selector: 'app-brightness-advanced-mode-toggle',
templateUrl: './brightness-advanced-mode-toggle.component.html',
styleUrl: './brightness-advanced-mode-toggle.component.scss',
animations: [hshrink()],
})
export class BrightnessAdvancedModeToggleComponent {
advancedMode = false;

constructor(
private modalService: ModalService,
private automationConfigService: AutomationConfigService
) {
this.automationConfigService.configs.pipe(takeUntilDestroyed()).subscribe((configs) => {
this.advancedMode = configs.BRIGHTNESS_AUTOMATIONS.advancedMode;
});
}
showModeInfoModal() {
this.modalService
.addModal<ConfirmModalInputModel, ConfirmModalOutputModel>(ConfirmModalComponent, {
title: 'brightness-automations.modeInfoModal.title',
message: 'brightness-automations.modeInfoModal.message',
confirmButtonText: 'shared.modals.ok',
showCancel: false,
})
.subscribe();
}

async toggleAdvancedMode() {
await this.automationConfigService.updateAutomationConfig<BrightnessAutomationsConfig>(
'BRIGHTNESS_AUTOMATIONS',
{ advancedMode: !this.advancedMode }
);
}
}
3 changes: 3 additions & 0 deletions src-ui/app/models/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export type AudioVolumeAutomation =

export interface BaseAudioVolumeAutomation {
type: AudioVolumeAutomationType;
applyOnStart: boolean;
audioDeviceRef: {
persistentId: string;
type: AudioDeviceType;
Expand Down Expand Up @@ -430,6 +431,7 @@ export interface ShutdownAutomationsConfig extends AutomationConfig {
triggerOnSleepActivationWindowEnd: [number, number];
triggerWhenAlone: boolean;
triggerWhenAloneDuration: number;
triggerWhenAloneOnlyWhenSleepModeActive: boolean;
triggerWhenAloneActivationWindow: boolean;
triggerWhenAloneActivationWindowStart: [number, number];
triggerWhenAloneActivationWindowEnd: [number, number];
Expand Down Expand Up @@ -753,6 +755,7 @@ export const AUTOMATION_CONFIGS_DEFAULT: AutomationConfigs = {
triggerOnSleepActivationWindowEnd: [7, 0],
triggerWhenAlone: false,
triggerWhenAloneDuration: 15 * 60 * 1000,
triggerWhenAloneOnlyWhenSleepModeActive: true,
triggerWhenAloneActivationWindow: false,
triggerWhenAloneActivationWindowStart: [23, 0],
triggerWhenAloneActivationWindowEnd: [7, 0],
Expand Down
29 changes: 28 additions & 1 deletion src-ui/app/services/audio-device-automations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { isEqual } from 'lodash';
import { SleepService } from './sleep.service';
import { SleepPreparationService } from './sleep-preparation.service';
import { distinctUntilChanged, firstValueFrom, map, skip } from 'rxjs';
import { delay, distinctUntilChanged, firstValueFrom, map, of, skip, switchMap, take } from 'rxjs';
import { AudioDeviceParsedName } from '../models/audio-device';
import { info } from 'tauri-plugin-log-api';
import { EventLogService } from './event-log.service';
Expand Down Expand Up @@ -40,6 +40,33 @@ export class AudioDeviceAutomationsService {
this.automationConfigService.configs.subscribe((configs) => {
this.config = configs.AUDIO_DEVICE_AUTOMATIONS;
});
// Run automations on OyasumiVR start
of(null)
.pipe(
delay(2000),
switchMap(() => this.sleepService.mode.pipe(take(1))),
map(
(sleepMode) =>
[
sleepMode
? this.config.onSleepEnableAutomations
: this.config.onSleepDisableAutomations,
sleepMode,
] as [AudioVolumeAutomation[], boolean]
),
map(
([automations, sleepMode]) =>
[automations.filter((a) => a.applyOnStart), sleepMode] as [
AudioVolumeAutomation[],
boolean
]
)
)
.subscribe(([automations, sleepMode]) => {
for (const automation of automations) {
this.runAutomation(automation, sleepMode ? 'SLEEP_MODE_ENABLED' : 'SLEEP_MODE_DISABLED');
}
});
// Run automations on sleep mode change
this.sleepService.mode.pipe(skip(1), distinctUntilChanged()).subscribe(async (sleepMode) => {
const automations = sleepMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ export class TurnOffDevicesOnBatteryLevelAutomationService {
case 'Controller':
if (!this.config.turnOffControllers) return;
if (this.config.turnOffControllersOnlyDuringSleepMode && !sleepMode) return;
if (currentLevel > this.config.turnOffControllersAtLevel) return;
if (currentLevel * 100 > this.config.turnOffControllersAtLevel) return;
threshold = this.config.turnOffControllersAtLevel;
break;
case 'GenericTracker':
if (!this.config.turnOffTrackers) return;
if (this.config.turnOffTrackersOnlyDuringSleepMode && !sleepMode) return;
if (currentLevel > this.config.turnOffTrackersAtLevel) return;
if (currentLevel * 100 > this.config.turnOffTrackersAtLevel) return;
threshold = this.config.turnOffTrackersAtLevel;
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src-ui/app/services/shutdown-automations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class ShutdownAutomationsService {
const keys: Array<keyof ShutdownAutomationsConfig> = [
'triggerWhenAlone',
'triggerWhenAloneDuration',
'triggerWhenAloneOnlyWhenSleepModeActive',
'triggerWhenAloneActivationWindow',
'triggerWhenAloneActivationWindowStart',
'triggerWhenAloneActivationWindowEnd',
Expand Down Expand Up @@ -231,6 +232,7 @@ export class ShutdownAutomationsService {
this.config.triggerWhenAloneActivationWindowEnd
)
),
filter(() => this.config.triggerWhenAloneOnlyWhenSleepModeActive || !this.sleepMode),
// Only trigger once every 5 minutes at most
throttleTime(300000, asyncScheduler, { leading: true, trailing: false })
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h3 translate>audio-volume-automations.onSleepEnable.title</h3>
<app-audio-volume-entries
[automations]="config.onSleepEnableAutomations"
(automationsChange)="onAutomationsChange('onSleepEnable', $event)"
[automationType]="'onSleepEnable'"
></app-audio-volume-entries>
</div>
<div class="setting-category">
Expand All @@ -16,6 +17,7 @@ <h3 translate>audio-volume-automations.onSleepDisable.title</h3>
<app-audio-volume-entries
[automations]="config.onSleepDisableAutomations"
(automationsChange)="onAutomationsChange('onSleepDisable', $event)"
[automationType]="'onSleepDisable'"
></app-audio-volume-entries>
</div>
<div class="setting-category">
Expand All @@ -24,6 +26,7 @@ <h3 translate>audio-volume-automations.onSleepPreparation.title</h3>
<app-audio-volume-entries
[automations]="config.onSleepPreparationAutomations"
(automationsChange)="onAutomationsChange('onSleepPreparation', $event)"
[automationType]="'onSleepPreparation'"
></app-audio-volume-entries>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div class="setting-row">
<div class="setting-row-label">
<span translate *ngIf="!automations.length"
>audio-volume-automations.devices.title.noDevices</span
>audio-volume-automations.devices.title.noDevices</span
>
<span translate *ngIf="automations.length"
>audio-volume-automations.devices.title.hasDevices</span
>audio-volume-automations.devices.title.hasDevices</span
>
<span translate>audio-volume-automations.devices.description</span>
</div>
Expand Down Expand Up @@ -51,8 +51,8 @@
</div>
<span>{{ automation.audioDeviceRef.name.display }}</span>
<span *ngIf="automation.audioDeviceRef.name.driver">{{
automation.audioDeviceRef.name.driver
}}</span>
automation.audioDeviceRef.name.driver
}}</span>
</div>
<div class="setting-row-action">
<app-select-box
Expand All @@ -72,8 +72,9 @@
</button>
</div>
</div>
<div class="setting-row-group" *ngIf="automation.type === 'SET_VOLUME'" @vshrink>
<div class="setting-row">
<div class="setting-row-group"
*ngIf="(automationType === 'onSleepEnable' || automationType === 'onSleepDisable') || automation.type === 'SET_VOLUME'" @vshrink>
<div class="setting-row" *ngIf="automation.type === 'SET_VOLUME'" @vshrink>
<div class="setting-row-label">
<span translate>audio-volume-automations.volume.title</span>
<span translate>audio-volume-automations.volume.description</span>
Expand All @@ -86,6 +87,22 @@
></app-slider-setting>
</div>
</div>
<div class="setting-row" *ngIf="automationType === 'onSleepEnable' || automationType === 'onSleepDisable'">
<div class="setting-row-label" translate>
<span translate>audio-volume-automations.applyOnStart.title</span>
<span translate>{{ 'audio-volume-automations.applyOnStart.description.' + automationType | translate }}</span>
</div>
<div class="setting-row-action">
<label class="switch-toggle">
<input
type="checkbox"
[checked]="automation.applyOnStart"
(change)="toggleApplyOnStart(automation)"
/>
<span class="switch-toggle-slider"></span>
</label>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
animations: [vshrink()],
})
export class AudioVolumeEntriesComponent implements OnInit {
@Input() automationType?: 'onSleepEnable' | 'onSleepDisable' | 'onSleepPreparation';
@Input() automations: AudioVolumeAutomation[] = [];
@Output() automationsChange: EventEmitter<AudioVolumeAutomation[]> = new EventEmitter();
collapsed = true;
Expand Down Expand Up @@ -104,6 +105,7 @@ export class AudioVolumeEntriesComponent implements OnInit {
this.automations.push({
type: 'SET_VOLUME',
volume: Math.round(res.device.volume * 100),
applyOnStart: true,
audioDeviceRef: {
persistentId: res.device.persistentId!,
type: res.device.deviceType,
Expand All @@ -124,4 +126,9 @@ export class AudioVolumeEntriesComponent implements OnInit {
trackAutomationBy(index: number, automation: AudioVolumeAutomation) {
return automation.audioDeviceRef.persistentId;
}

toggleApplyOnStart(automation: AudioVolumeAutomation) {
automation.applyOnStart = !automation.applyOnStart;
this.automationsChange.emit(this.automations);
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
<div class="pane">
<div class="pane-title">
<span translate>brightness-automations.title</span>
<div class="advanced-toggle">
<div class="advanced-toggle-clickable" (click)="toggleAdvancedMode()">
<label class="switch-toggle">
<input type="checkbox" [checked]="advancedMode" disabled />
<span class="switch-toggle-slider"></span>
</label>
<span @hshrink *ngIf="!advancedMode" translate>brightness-automations.mode.simple</span>
<span @hshrink *ngIf="advancedMode" translate>brightness-automations.mode.advanced</span>
</div>
<i class="material-icons-round help-icon" (click)="showModeInfoModal()">help</i>
</div>
<app-brightness-advanced-mode-toggle></app-brightness-advanced-mode-toggle>
</div>
<div class="pane-content">
<app-brightness-automations-tab></app-brightness-automations-tab>
Expand Down
Loading

0 comments on commit 5b73007

Please sign in to comment.