Skip to content

Commit

Permalink
force events to run regardless of previous state via --update
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKratz committed Jan 30, 2023
1 parent f4b439e commit bf939fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern int g_connection;
extern bool g_brightness_events;


float g_last_brightness = -1;
float g_last_brightness = -1.f;
static void brightness_handler(void* notification_center, uint32_t did, void* name, const void* sender, CFDictionaryRef info) {
float* brightness = malloc(sizeof(float));
memset(brightness, 0, sizeof(float));
Expand Down Expand Up @@ -256,6 +256,7 @@ bool display_end() {
}

void forced_brightness_event() {
g_last_brightness = -1.f;
brightness_handler(NULL, display_active_display_id(), NULL, NULL, NULL);
}

Expand Down
1 change: 1 addition & 0 deletions src/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void power_handler(void* context) {
}

void forced_power_event() {
g_power_source = 0;
power_handler(NULL);
}

Expand Down
1 change: 1 addition & 0 deletions src/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ OSStatus device_changed(AudioObjectID id, uint32_t address_count, const AudioObj
}

void forced_volume_event() {
g_last_volume = -1.f;
handler(g_audio_id, 0, 0, 0);
}

Expand Down
5 changes: 5 additions & 0 deletions src/wifi.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ void update_ssid(SCDynamicStoreRef store, CFArrayRef keys, void* info) {
ssid[[data length]] = '\0';

if (!g_current_ssid || strcmp(g_current_ssid, ssid) != 0) {
if (g_current_ssid) free(g_current_ssid);
g_current_ssid = string_copy(ssid);

struct event *event = event_create(&g_event_loop,
WIFI_CHANGED,
(void *) ssid );
Expand All @@ -23,6 +26,8 @@ void update_ssid(SCDynamicStoreRef store, CFArrayRef keys, void* info) {
}

void forced_network_event() {
if (g_current_ssid) free(g_current_ssid);
g_current_ssid = NULL;
update_ssid(NULL, NULL, NULL);
}

Expand Down

0 comments on commit bf939fa

Please sign in to comment.