Checkupdates & Divider Functions
- Add checkupdates function to count number of available updates - Add divider function to print divider symbol as argument - Update README with these modifications
This commit is contained in:
2
Makefile
2
Makefile
@@ -7,9 +7,11 @@ include config.mk
|
||||
REQ = util
|
||||
COM =\
|
||||
components/battery\
|
||||
components/check_updates\
|
||||
components/cpu\
|
||||
components/datetime\
|
||||
components/disk\
|
||||
components/divider\
|
||||
components/entropy\
|
||||
components/hostname\
|
||||
components/ip\
|
||||
|
@@ -65,7 +65,7 @@ Cleaning up the whole codebase it the goal before thinking about a release.
|
||||
|
||||
* Change unknown string to "?"
|
||||
* Customize Status Bar
|
||||
* User
|
||||
* Username
|
||||
* CPU Usage
|
||||
* RAM Usage
|
||||
* Disk Usage
|
||||
@@ -73,3 +73,6 @@ Cleaning up the whole codebase it the goal before thinking about a release.
|
||||
* Battery Stats
|
||||
* Date
|
||||
* Time
|
||||
* Custom Functions
|
||||
* **check_updates** uses **run_command** to get number of packages that need to be updated
|
||||
* **divider** prints the *divider_symbol* via a separate function rather than in the format of another function
|
||||
|
12
components/check_updates.c
Normal file
12
components/check_updates.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../slstatus.h"
|
||||
|
||||
const char *
|
||||
check_updates(void)
|
||||
{
|
||||
const char *cmd = "checkupdates | wc -l";
|
||||
return run_command(cmd);
|
||||
}
|
9
components/divider.c
Normal file
9
components/divider.c
Normal file
@@ -0,0 +1,9 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *
|
||||
divider(const char *div)
|
||||
{
|
||||
return div;
|
||||
}
|
32
config.h
32
config.h
@@ -10,6 +10,7 @@ static const char unknown_str[] = "?";
|
||||
#define MAXLEN 2048
|
||||
|
||||
static const char battery_name[] = "BAT0";
|
||||
static const char divider_symbol[] = "|";
|
||||
|
||||
/*
|
||||
* function description argument (example)
|
||||
@@ -20,6 +21,7 @@ static const char battery_name[] = "BAT0";
|
||||
* NULL on OpenBSD/FreeBSD
|
||||
* battery_remaining battery remaining HH:MM battery name (BAT0)
|
||||
* NULL on OpenBSD/FreeBSD
|
||||
* check_updates num available updates NULL
|
||||
* cpu_perc cpu usage in percent NULL
|
||||
* cpu_freq cpu frequency in MHz NULL
|
||||
* datetime date and time format string (%F %T)
|
||||
@@ -27,6 +29,7 @@ static const char battery_name[] = "BAT0";
|
||||
* disk_perc disk usage in percent mountpoint path (/)
|
||||
* disk_total total disk space in GB mountpoint path (/")
|
||||
* disk_used used disk space in GB mountpoint path (/)
|
||||
* divider insert divider divider symbol
|
||||
* entropy available entropy NULL
|
||||
* gid GID of current user NULL
|
||||
* hostname hostname NULL
|
||||
@@ -64,15 +67,24 @@ static const char battery_name[] = "BAT0";
|
||||
* wifi_essid WiFi ESSID interface name (wlan0)
|
||||
*/
|
||||
static const struct arg args[] = {
|
||||
/* function format argument */
|
||||
{ username, "| %s ", NULL },
|
||||
{ cpu_perc, "| %s%% ", NULL },
|
||||
{ ram_perc, "| %s%% ", NULL },
|
||||
{ disk_perc, "| %s%% ", "/home" },
|
||||
{ run_command, "| %s ", "checkupdates | wc -l" },
|
||||
{ battery_state, "| %s", battery_name },
|
||||
/* function format argument */
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ username, " %s", NULL },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ cpu_perc, " %s%%", NULL },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ ram_perc, " %s%%", NULL },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ disk_perc, " %s%%", "/home" },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ check_updates, " %s", NULL },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ battery_state, " %s", battery_name },
|
||||
{ battery_perc, "%s%%", battery_name },
|
||||
{ battery_remaining, " (%s) ", battery_name },
|
||||
{ datetime, "| %s ", "%a %x" },
|
||||
{ datetime, "| %s |", "%I:%M:%S %p" },
|
||||
{ battery_remaining, " (%s)", battery_name },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ datetime, " %s", "%a %x" },
|
||||
{ divider, "%s", divider_symbol },
|
||||
{ datetime, " %s", "%I:%M:%S %p" },
|
||||
{ divider, "%s", divider_symbol },
|
||||
};
|
||||
|
@@ -5,6 +5,9 @@ const char *battery_perc(const char *);
|
||||
const char *battery_state(const char *);
|
||||
const char *battery_remaining(const char *);
|
||||
|
||||
/* check updates */
|
||||
const char *check_updates(void);
|
||||
|
||||
/* cpu */
|
||||
const char *cpu_freq(void);
|
||||
const char *cpu_perc(void);
|
||||
@@ -18,6 +21,9 @@ const char *disk_perc(const char *path);
|
||||
const char *disk_total(const char *path);
|
||||
const char *disk_used(const char *path);
|
||||
|
||||
/* divider */
|
||||
const char *divider(const char *div);
|
||||
|
||||
/* entropy */
|
||||
const char *entropy(void);
|
||||
|
||||
|
Reference in New Issue
Block a user