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
|
REQ = util
|
||||||
COM =\
|
COM =\
|
||||||
components/battery\
|
components/battery\
|
||||||
|
components/check_updates\
|
||||||
components/cpu\
|
components/cpu\
|
||||||
components/datetime\
|
components/datetime\
|
||||||
components/disk\
|
components/disk\
|
||||||
|
components/divider\
|
||||||
components/entropy\
|
components/entropy\
|
||||||
components/hostname\
|
components/hostname\
|
||||||
components/ip\
|
components/ip\
|
||||||
|
@@ -65,7 +65,7 @@ Cleaning up the whole codebase it the goal before thinking about a release.
|
|||||||
|
|
||||||
* Change unknown string to "?"
|
* Change unknown string to "?"
|
||||||
* Customize Status Bar
|
* Customize Status Bar
|
||||||
* User
|
* Username
|
||||||
* CPU Usage
|
* CPU Usage
|
||||||
* RAM Usage
|
* RAM Usage
|
||||||
* Disk Usage
|
* Disk Usage
|
||||||
@@ -73,3 +73,6 @@ Cleaning up the whole codebase it the goal before thinking about a release.
|
|||||||
* Battery Stats
|
* Battery Stats
|
||||||
* Date
|
* Date
|
||||||
* Time
|
* 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
|
#define MAXLEN 2048
|
||||||
|
|
||||||
static const char battery_name[] = "BAT0";
|
static const char battery_name[] = "BAT0";
|
||||||
|
static const char divider_symbol[] = "|";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function description argument (example)
|
* function description argument (example)
|
||||||
@@ -20,6 +21,7 @@ static const char battery_name[] = "BAT0";
|
|||||||
* NULL on OpenBSD/FreeBSD
|
* NULL on OpenBSD/FreeBSD
|
||||||
* battery_remaining battery remaining HH:MM battery name (BAT0)
|
* battery_remaining battery remaining HH:MM battery name (BAT0)
|
||||||
* NULL on OpenBSD/FreeBSD
|
* NULL on OpenBSD/FreeBSD
|
||||||
|
* check_updates num available updates NULL
|
||||||
* cpu_perc cpu usage in percent NULL
|
* cpu_perc cpu usage in percent NULL
|
||||||
* cpu_freq cpu frequency in MHz NULL
|
* cpu_freq cpu frequency in MHz NULL
|
||||||
* datetime date and time format string (%F %T)
|
* 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_perc disk usage in percent mountpoint path (/)
|
||||||
* disk_total total disk space in GB mountpoint path (/")
|
* disk_total total disk space in GB mountpoint path (/")
|
||||||
* disk_used used disk space in GB mountpoint path (/)
|
* disk_used used disk space in GB mountpoint path (/)
|
||||||
|
* divider insert divider divider symbol
|
||||||
* entropy available entropy NULL
|
* entropy available entropy NULL
|
||||||
* gid GID of current user NULL
|
* gid GID of current user NULL
|
||||||
* hostname hostname NULL
|
* hostname hostname NULL
|
||||||
@@ -64,15 +67,24 @@ static const char battery_name[] = "BAT0";
|
|||||||
* wifi_essid WiFi ESSID interface name (wlan0)
|
* wifi_essid WiFi ESSID interface name (wlan0)
|
||||||
*/
|
*/
|
||||||
static const struct arg args[] = {
|
static const struct arg args[] = {
|
||||||
/* function format argument */
|
/* function format argument */
|
||||||
{ username, "| %s ", NULL },
|
{ divider, "%s", divider_symbol },
|
||||||
{ cpu_perc, "| %s%% ", NULL },
|
{ username, " %s", NULL },
|
||||||
{ ram_perc, "| %s%% ", NULL },
|
{ divider, "%s", divider_symbol },
|
||||||
{ disk_perc, "| %s%% ", "/home" },
|
{ cpu_perc, " %s%%", NULL },
|
||||||
{ run_command, "| %s ", "checkupdates | wc -l" },
|
{ divider, "%s", divider_symbol },
|
||||||
{ battery_state, "| %s", battery_name },
|
{ 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_perc, "%s%%", battery_name },
|
||||||
{ battery_remaining, " (%s) ", battery_name },
|
{ battery_remaining, " (%s)", battery_name },
|
||||||
{ datetime, "| %s ", "%a %x" },
|
{ divider, "%s", divider_symbol },
|
||||||
{ datetime, "| %s |", "%I:%M:%S %p" },
|
{ 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_state(const char *);
|
||||||
const char *battery_remaining(const char *);
|
const char *battery_remaining(const char *);
|
||||||
|
|
||||||
|
/* check updates */
|
||||||
|
const char *check_updates(void);
|
||||||
|
|
||||||
/* cpu */
|
/* cpu */
|
||||||
const char *cpu_freq(void);
|
const char *cpu_freq(void);
|
||||||
const char *cpu_perc(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_total(const char *path);
|
||||||
const char *disk_used(const char *path);
|
const char *disk_used(const char *path);
|
||||||
|
|
||||||
|
/* divider */
|
||||||
|
const char *divider(const char *div);
|
||||||
|
|
||||||
/* entropy */
|
/* entropy */
|
||||||
const char *entropy(void);
|
const char *entropy(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user