Skip to content

Commit

Permalink
Conky for mac os master (brndnmtthws#579)
Browse files Browse the repository at this point in the history
* Try to amend #31

* BUILD_WLAN should be available for all OS.

Keep BUILD_WLAN OFF by default for compatibility reasons.

* WLAN-related variables should be available for every OS.

There are some problems (probably null-dereference)

* Fix $wireless_essid crashing conky if no argument provided.

Conky wasn't parsing the argument of the variable as it should, thus wasn't allocating the `dev` member variable.

Also fix some documentation stuff.

* Improve `get_freq` #20

Using the Intel® Power Gadget API (https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x) we can now get actual Core frequency and not the constant factory one.

Though, for some weird reason the API gives the same freq for all Cores, thus the |cpu| arg becomes useless.

* Oops, this accidently slipped in

* Introduce BUILD_IPGFREQ build option

This build option has been introduced for one particular reason:

On macOS getting current core-frequency is not supported by the APIs.  A solution is to install Intel's ® Power Gadget which comes with an .app, a Framework and a kernel-extension.  Though, this may trouble some alot, thus introduce BUILD_IPGFREQ.

* Forgot static here.

* Some improvements for get_freq again.

Fix frequency not printing correctly (I wasn't using the divisor)
Add more guards.

* Setup cmake files and project code for Objective-C code #17

We want to use CoreWLAN framework.

* update_cpu_usage() now supports multiple cores

Also, some cleanup.

* Updated default conky config to monitor Mac Networking

* Made Mac Friendly BuildOptions and generic default conky configs

* Undid Xdamage config and cleaned up previous IF statements

* Re-Added XDamage fix

* Finish up the algorithm. I think its now correct. Closes: #33

* Cleanup macro and introduce a no-op free_cpu() function for ALL cpu-related variables

free_cpu() must be implemented for every OS and on all except macOS its a no-op function.

* Reformat, add empty comment.
  • Loading branch information
brndnmtthws authored Aug 7, 2018
1 parent b17f2c2 commit 8aa9c81
Show file tree
Hide file tree
Showing 19 changed files with 228 additions and 153 deletions.
24 changes: 21 additions & 3 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ if (NOT LIB_INSTALL_DIR)
endif (NOT LIB_INSTALL_DIR)
set(PACKAGE_LIBRARY_DIR "${LIB_INSTALL_DIR}/conky" CACHE STRING "Package library path (where Lua bindings are installed" FORCE)
set(DEFAULTNETDEV "eth0" CACHE STRING "Default networkdevice")

# Mac only override
if(OS_DARWIN)
set(DEFAULTNETDEV "en0" CACHE STRING "Default networkdevice" FORCE)
endif(OS_DARWIN)

set(XDG_CONFIG_FILE "$HOME/.config/conky/conky.conf" CACHE STRING "Configfile of the user (XDG)")
set(CONFIG_FILE "$HOME/.conkyrc" CACHE STRING "Configfile of the user")
set(MAX_USER_TEXT_DEFAULT "16384" CACHE STRING "Default maximum size of config TEXT buffer, i.e. below TEXT line.")
Expand All @@ -76,22 +82,27 @@ if(OS_LINUX)
option(BUILD_PORT_MONITORS "Build TCP portmon support" true)
option(BUILD_IBM "Support for IBM/Lenovo notebooks" true)
option(BUILD_HDDTEMP "Support for hddtemp" true)
option(BUILD_WLAN "Enable wireless support" false)
# nvidia may also work on FreeBSD, not sure
option(BUILD_NVIDIA "Enable nvidia support" false)
option(BUILD_IPV6 "Enable if you want IPv6 support" true)
else(OS_LINUX)
set(BUILD_PORT_MONITORS false)
set(BUILD_IBM false)
set(BUILD_HDDTEMP false)
set(BUILD_WLAN false)
set(BUILD_NVIDIA false)
set(BUILD_IPV6 false)
endif(OS_LINUX)

# macOS Only
if(OS_DARWIN)
option(BUILD_IPGFREQ "Enable cpu freq calculation based on Intel® Power Gadget; otherwise use constant factory value" false)
endif(OS_DARWIN)

# Optional features etc
#

option(BUILD_WLAN "Enable wireless support" false)

option(BUILD_BUILTIN_CONFIG "Enable builtin default configuration" true)

option(BUILD_IOSTATS "Enable disk I/O stats" true)
Expand All @@ -110,7 +121,14 @@ endif(BUILD_NCURSES)
option(BUILD_X11 "Build X11 support" true)
if(BUILD_X11)
option(OWN_WINDOW "Enable own_window support" true)
option(BUILD_XDAMAGE "Build Xdamage support" true)

# Mac Fix
if(OS_DARWIN)
option(BUILD_XDAMAGE "Build Xdamage support" false)
else(OS_DARWIN)
option(BUILD_XDAMAGE "Build Xdamage support" true)
endif(OS_DARWIN)

option(BUILD_XINERAMA "Build Xinerama support" true)
option(BUILD_XDBE "Build Xdbe (double-buffer) support" true)
option(BUILD_XFT "Build Xft (freetype fonts) support" true)
Expand Down
14 changes: 12 additions & 2 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ if(BUILD_NCURSES AND OS_DARWIN)
set(conky_libs ${conky_libs} -lncurses)
endif(BUILD_NCURSES AND OS_DARWIN)

if(BUILD_WLAN AND OS_DARWIN)
find_library(CW CoreWLAN)
set(conky_libs ${conky_libs} ${CW})
endif(BUILD_WLAN AND OS_DARWIN)

if(OS_DARWIN AND BUILD_IPGFREQ)
find_library(IPG IntelPowerGadget)
set(conky_libs ${conky_libs} ${IPG})
endif(OS_DARWIN AND BUILD_IPGFREQ)

if(BUILD_MATH)
set(conky_libs ${conky_libs} -lm)
endif(BUILD_MATH)
Expand Down Expand Up @@ -198,7 +208,7 @@ if(BUILD_MYSQL)
set(conky_libs ${conky_libs} ${MYSQLCLIENT_LIB})
endif(BUILD_MYSQL)

if(BUILD_WLAN)
if(BUILD_WLAN AND OS_LINUX)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_include_files(iwlib.h IWLIB_H)
if(NOT IWLIB_H)
Expand All @@ -210,7 +220,7 @@ if(BUILD_WLAN)
endif(NOT IWLIB_LIB)
set(conky_libs ${conky_libs} ${IWLIB_LIB})
check_function_exists(iw_sockets_open IWLIB_SOCKETS_OPEN_FUNC)
endif(BUILD_WLAN)
endif(BUILD_WLAN AND OS_LINUX)

if(BUILD_PORT_MONITORS)
check_function_exists(getnameinfo HAVE_GETNAMEINFO)
Expand Down
2 changes: 2 additions & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@

#cmakedefine BUILD_IOSTATS 1

#cmakedefine BUILD_IPGFREQ 0

#cmakedefine BUILD_WLAN 1

#cmakedefine BUILD_ICAL 1
Expand Down
2 changes: 1 addition & 1 deletion data/conky.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ $hr
${color grey}File systems:
/ $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
${color grey}Networking:
Up:$color ${upspeed eth0} ${color grey} - Down:$color ${downspeed eth0}
Up:$color ${upspeed} ${color grey} - Down:$color ${downspeed}
$hr
${color grey}Name PID CPU% MEM%
${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
Expand Down
2 changes: 1 addition & 1 deletion data/conky_no_x11.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Processes: $processes Running: $running_processes
File systems:
/ ${fs_used /}/${fs_size /} ${fs_bar 6 /}
Networking:
Up: ${upspeed eth0} - Down: ${downspeed eth0}
Up: ${upspeed} - Down: ${downspeed}
Name PID CPU% MEM%
${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
Expand Down
4 changes: 2 additions & 2 deletions doc/variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4784,7 +4784,7 @@
</command>
<option>(net)</option>
</term>
<listitem>WLAN channel on which device 'net' is listening (Linux only)
<listitem>WLAN channel on which device 'net' is listening
<para /></listitem>
</varlistentry>
<varlistentry>
Expand All @@ -4804,7 +4804,7 @@
</command>
<option>(net)</option>
</term>
<listitem>Frequency on which device 'net' is listening (Linux only)
<listitem>Frequency on which device 'net' is listening
<para /></listitem>
</varlistentry>
<varlistentry>
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ endif(OS_HAIKU)

if(OS_DARWIN)
set(darwin
darwin.cc darwin.h
darwin.mm darwin.h
darwin_sip.h
i18n.h
)
Expand Down
2 changes: 2 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ uint8_t battery_percentage(struct text_object *);
void print_battery_short(struct text_object *, char *, int);
#endif /* !__OpenBSD__ */

void free_cpu(struct text_object *);

void print_blink(struct text_object *, char *, int);
void print_include(struct text_object *, char *, int);

Expand Down
71 changes: 38 additions & 33 deletions src/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,42 +484,43 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->data.i = atoi(&arg[0]);
}
obj->callbacks.print = &print_voltage_v;

#endif /* __linux__ */

#ifdef BUILD_WLAN
END OBJ(wireless_essid, &update_net_stats) obj->data.opaque =
get_net_stat(arg, obj, free_at_crash);
obj->callbacks.print = &print_wireless_essid;
END OBJ(wireless_channel, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_channel;
END OBJ(wireless_freq, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_frequency;
END OBJ(wireless_mode, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_mode;
END OBJ(wireless_bitrate, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_bitrate;
END OBJ(wireless_ap, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_ap;
END OBJ(wireless_link_qual, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_link_qual;
END OBJ(wireless_link_qual_max, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_link_qual_max;
END OBJ(wireless_link_qual_perc, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_link_qual_perc;
END OBJ(wireless_link_bar, &update_net_stats)
parse_net_stat_bar_arg(obj, arg, free_at_crash);
obj->callbacks.barval = &wireless_link_barval;
END OBJ(wireless_essid, &update_net_stats) obj->data.opaque =
get_net_stat(arg, obj, free_at_crash);
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_essid;
END OBJ(wireless_channel, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_channel;
END OBJ(wireless_freq, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_frequency;
END OBJ(wireless_mode, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_mode;
END OBJ(wireless_bitrate, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_bitrate;
END OBJ(wireless_ap, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_ap;
END OBJ(wireless_link_qual, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_link_qual;
END OBJ(wireless_link_qual_max, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_link_qual_max;
END OBJ(wireless_link_qual_perc, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_link_qual_perc;
END OBJ(wireless_link_bar, &update_net_stats)
parse_net_stat_bar_arg(obj, arg, free_at_crash);
obj->callbacks.barval = &wireless_link_barval;
#endif /* BUILD_WLAN */

#endif /* __linux__ */


#ifndef __OpenBSD__
END OBJ(acpifan, nullptr) obj->callbacks.print = &print_acpifan;
END OBJ(battery, nullptr) char bat[64];
Expand Down Expand Up @@ -673,18 +674,21 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(cpu, &update_cpu_usage) get_cpu_count();
SCAN_CPU(arg, obj->data.i);
obj->callbacks.percentage = &cpu_percentage;
obj->callbacks.free = &free_cpu;
DBGP2("Adding $cpu for CPU %d", obj->data.i);
#ifdef BUILD_X11
END OBJ(cpugauge, &update_cpu_usage) get_cpu_count();
SCAN_CPU(arg, obj->data.i);
scan_gauge(obj, arg, 1);
obj->callbacks.gaugeval = &cpu_barval;
obj->callbacks.free = &free_cpu;
DBGP2("Adding $cpugauge for CPU %d", obj->data.i);
#endif
END OBJ(cpubar, &update_cpu_usage) get_cpu_count();
SCAN_CPU(arg, obj->data.i);
scan_bar(obj, arg, 1);
obj->callbacks.barval = &cpu_barval;
obj->callbacks.free = &free_cpu;
DBGP2("Adding $cpubar for CPU %d", obj->data.i);
#ifdef BUILD_X11
END OBJ(cpugraph, &update_cpu_usage) get_cpu_count();
Expand All @@ -694,6 +698,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
free_and_zero(buf);
obj->callbacks.graphval = &cpu_barval;
obj->callbacks.free = &free_cpu;
END OBJ(loadgraph, &update_load_average) scan_loadgraph_arg(obj, arg);
obj->callbacks.graphval = &loadgraphval;
#endif /* BUILD_X11 */
Expand Down
2 changes: 2 additions & 0 deletions src/darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ int get_entropy_poolsize(const unsigned int *);
int get_sip_status(void);
void print_sip_status(struct text_object *obj, char *p, int p_max_size);

void deallocate_cpu_sample(struct text_object *obj);

#endif /*DARWIN_H*/
Loading

0 comments on commit 8aa9c81

Please sign in to comment.