mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 13:00:45 +00:00
make times_in_seconds a lua setting
This commit is contained in:
parent
b713536dad
commit
48346c8325
@ -211,7 +211,7 @@ void format_seconds(char *buf, unsigned int n, long seconds)
|
||||
long days;
|
||||
int hours, minutes;
|
||||
|
||||
if (times_in_seconds()) {
|
||||
if (times_in_seconds.get(*state)) {
|
||||
snprintf(buf, n, "%ld", seconds);
|
||||
return;
|
||||
}
|
||||
@ -235,7 +235,7 @@ void format_seconds_short(char *buf, unsigned int n, long seconds)
|
||||
long days;
|
||||
int hours, minutes;
|
||||
|
||||
if (times_in_seconds()) {
|
||||
if (times_in_seconds.get(*state)) {
|
||||
snprintf(buf, n, "%ld", seconds);
|
||||
return;
|
||||
}
|
||||
|
@ -2585,8 +2585,6 @@ static void set_default_configurations(void)
|
||||
stuff_in_uppercase = 0;
|
||||
info.users.number = 1;
|
||||
|
||||
set_times_in_seconds(0);
|
||||
|
||||
#ifdef BUILD_PORT_MONITORS
|
||||
/* set default connection limit */
|
||||
tcp_portmon_set_max_connections(0);
|
||||
@ -2981,9 +2979,6 @@ char load_config_file(const char *f)
|
||||
utf8_mode = string_to_bool(value);
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
CONF("times_in_seconds") {
|
||||
set_times_in_seconds(string_to_bool(value));
|
||||
}
|
||||
CONF("max_text_width") {
|
||||
max_text_width = atoi(value);
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ static inline void format_media_player_time(char *buf, const int size,
|
||||
{
|
||||
int days, hours, minutes;
|
||||
|
||||
if (times_in_seconds()) {
|
||||
if (times_in_seconds.get(*state)) {
|
||||
snprintf(buf, size, "%d", seconds);
|
||||
return;
|
||||
}
|
||||
|
@ -28,6 +28,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "timeinfo.h"
|
||||
|
||||
#include "conky.h"
|
||||
#include "text_object.h"
|
||||
#include <locale.h>
|
||||
@ -38,22 +42,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
char print_times_in_seconds = 0;
|
||||
|
||||
struct tztime_s {
|
||||
char *tz; /* timezone variable */
|
||||
char *fmt; /* time display formatting */
|
||||
};
|
||||
|
||||
void set_times_in_seconds(char val)
|
||||
{
|
||||
print_times_in_seconds = val;
|
||||
}
|
||||
|
||||
char times_in_seconds(void)
|
||||
{
|
||||
return print_times_in_seconds;
|
||||
}
|
||||
conky::simple_config_setting<bool> times_in_seconds("times_in_seconds", false, false);
|
||||
|
||||
void scan_time(struct text_object *obj, const char *arg)
|
||||
{
|
||||
@ -171,7 +165,7 @@ static void do_format_time(struct text_object *obj, char *p, unsigned int p_max_
|
||||
int minutes, hours, days, weeks;
|
||||
char show_minutes = 0, show_hours = 0, show_days = 0, show_weeks = 0, hidestring;
|
||||
|
||||
if (!times_in_seconds()) {
|
||||
if (not times_in_seconds.get(*state)) {
|
||||
NORM_ERR("Enable \"times_in_seconds\" to use $format_time");
|
||||
return;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@
|
||||
#ifndef _TIMEINFO_H
|
||||
#define _TIMEINFO_H
|
||||
|
||||
/* for the times_in_seconds configuration variable and it's users */
|
||||
void set_times_in_seconds(char);
|
||||
char times_in_seconds(void);
|
||||
#include "setting.hh"
|
||||
|
||||
extern conky::simple_config_setting<bool> times_in_seconds;
|
||||
|
||||
/* since time and utime are quite equal, certain functions
|
||||
* are shared in between both text object types. */
|
||||
|
Loading…
Reference in New Issue
Block a user