mirror of
https://github.com/javalsai/lidm.git
synced 2025-09-03 19:58:01 +02:00
style: formatting and linter satisfaction
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
// Small file to save last selection
|
||||
// Small file for saving last selection
|
||||
|
||||
#define STATE_PATH "/var/lib/lidm/state"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "launch_state.h"
|
||||
|
||||
struct LaunchState read_launch_state() {
|
||||
struct LaunchState state;
|
||||
state.user_opt = 1;
|
||||
state.session_opt = 1;
|
||||
FILE* f = fopen(STATE_PATH, "r");
|
||||
if(!f) return state;
|
||||
fscanf(f, "%i;%i", &state.user_opt, &state.session_opt);
|
||||
fclose(f);
|
||||
return state;
|
||||
struct LaunchState state;
|
||||
state.user_opt = 1;
|
||||
state.session_opt = 1;
|
||||
FILE* state_fd = fopen(STATE_PATH, "r");
|
||||
if (!state_fd) return state;
|
||||
if (fscanf(state_fd, "%i;%i", &state.user_opt, &state.session_opt) != 2) {
|
||||
state.user_opt = 1;
|
||||
state.session_opt = 1;
|
||||
}
|
||||
(void)fclose(state_fd);
|
||||
return state;
|
||||
}
|
||||
|
||||
bool write_launch_state(struct LaunchState state) {
|
||||
FILE* f = fopen(STATE_PATH, "w");
|
||||
if(!f) return false;
|
||||
fprintf(f, "%i;%i", state.user_opt, state.session_opt);
|
||||
fclose(f);
|
||||
return true;
|
||||
FILE* state_fd = fopen(STATE_PATH, "w");
|
||||
if (!state_fd) return false;
|
||||
(void)fprintf(state_fd, "%i;%i", state.user_opt, state.session_opt);
|
||||
(void)fclose(state_fd);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user