commit ace407a034e686dbfb8873a6386a74abff9d88da
parent f85e066cddf0285e0eefc0d33f620d255497af04
Author: tongong <tongong@gmx.net>
Date: Tue, 20 Jul 2021 14:50:51 +0200
formatting and readme fixes
Diffstat:
2 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/suckless/README.md b/suckless/README.md
@@ -12,6 +12,7 @@ something like `git subtree` in the future.
- from https://github.com/Hendrikto/backlight_control
- renamed from `backlight_control` to `backlight-control`
- added `backlight-control get` command
+- added option to update my statusbar after changes
## clipmenu & clipnotify
- not modified by me, but it's there nevertheless lol
diff --git a/suckless/backlight-control/backlight-control.c b/suckless/backlight-control/backlight-control.c
@@ -19,25 +19,25 @@ char *notify_cmd[]={"sigdsblocks", "9", NULL};
#define MIN(a, b) ((a < b) ? a : b)
void print_usage(char *name) {
- printf(
- "Usage: %1$s [+|-]<value>\n"
- "\n"
- "Examples:\n"
- "\t%1$s +10\n"
- "\t%1$s -10\n"
- "\t%1$s 50\n"
- "\t%1$s get\n",
- name
- );
+ printf(
+ "Usage: %1$s [+|-]<value>\n"
+ "\n"
+ "Examples:\n"
+ "\t%1$s +10\n"
+ "\t%1$s -10\n"
+ "\t%1$s 50\n"
+ "\t%1$s get\n",
+ name
+ );
}
FILE *open_file(char *name) {
- FILE *file;
- if (!(file = fopen(name, "r+"))) {
- fprintf(stderr, "failed to open %s\n", name);
- exit(EXIT_FAILURE);
- }
- return file;
+ FILE *file;
+ if (!(file = fopen(name, "r+"))) {
+ fprintf(stderr, "failed to open %s\n", name);
+ exit(EXIT_FAILURE);
+ }
+ return file;
}
unsigned int round_closest(unsigned int dividend, unsigned int divisor)
@@ -46,10 +46,10 @@ unsigned int round_closest(unsigned int dividend, unsigned int divisor)
}
int main(int argc, char **argv) {
- if (argc != 2) {
- print_usage(argv[0]);
- return EXIT_FAILURE;
- }
+ if (argc != 2) {
+ print_usage(argv[0]);
+ return EXIT_FAILURE;
+ }
if (!strcmp(argv[1], "get")) {
int brightness_value;
@@ -61,23 +61,23 @@ int main(int argc, char **argv) {
return EXIT_SUCCESS;
}
- int value = strtol(argv[1], NULL, 10);
- FILE *brightness = open_file(BRIGHTNESS_FILE);
- int brightness_value = MIN_BRIGHTNESS;
- switch (argv[1][0]) {
- case '+':
- case '-':
- fscanf(brightness, "%d", &brightness_value);
- brightness_value += MAX_BRIGHTNESS * value / 100;
- break;
- default:
- brightness_value = MAX_BRIGHTNESS * value / 100;
- }
- brightness_value = MIN(brightness_value, MAX_BRIGHTNESS);
- brightness_value = MAX(brightness_value, MIN_BRIGHTNESS);
- fprintf(brightness, "%d", brightness_value);
- fclose(brightness);
+ int value = strtol(argv[1], NULL, 10);
+ FILE *brightness = open_file(BRIGHTNESS_FILE);
+ int brightness_value = MIN_BRIGHTNESS;
+ switch (argv[1][0]) {
+ case '+':
+ case '-':
+ fscanf(brightness, "%d", &brightness_value);
+ brightness_value += MAX_BRIGHTNESS * value / 100;
+ break;
+ default:
+ brightness_value = MAX_BRIGHTNESS * value / 100;
+ }
+ brightness_value = MIN(brightness_value, MAX_BRIGHTNESS);
+ brightness_value = MAX(brightness_value, MIN_BRIGHTNESS);
+ fprintf(brightness, "%d", brightness_value);
+ fclose(brightness);
- execvp(notify_cmd[0],notify_cmd);
- return EXIT_SUCCESS;
+ execvp(notify_cmd[0], notify_cmd);
+ return EXIT_SUCCESS;
}