1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 20:11:11 +00:00

Basic macOS support (#480)

* Initial patches for Darwin support

* cmake files ready for building on Sierra. Dont know about other OSX versions

* Added darwin.h which will contain darwin specific headers

* Patches for enablin asprintf support (needs _POSIX_C_SOURCE >= __DARWIN_C_FULL so remove -D_POSIX_C_SOURCE=200809L).  What is more, -D_LARGEFILE64_SOURCE is used by default so not needed on macOS

* Stubs for get_entropy_avail and get_entropy_poolsize

* More progress to getting to build

* More patches

* Now builds, remains fixing linking errors. Also implemented some functions

* Now links

* Now conky runs without sigabrt()'ing... An exception in semaphore.hh caused it to crash immediately upon initialisation

* README changes

* This was based on an old attempt I did with porting conky where I hadn't cloned the repo and thus it showed 3166 commits behind

* Patched a bit the semaphore.hh and now conky runs at 0.7% CPU usage and not in 100% or 200% as it did before! Yeah

* This update fixes swap-related miscalculations, though:

On macOS there can be used MANY swapfiles ( NOT swap partitions,,, the installation disk is the partition for storing swap memory data )
Thus conky code must be updated for Darwin to support multi-swapfile usage stats.

For now, we default to showing stats for swapfile0

* Fixed a bit the comments so they make sense

* Realised that the sysctl code can give us stats for the whole swap storage so removed the swapmode( int swapfd, unsigned long * retvail, unsigned long * retfree )

* I think the code is in good condition now

* semaphore.hh: Implemented ~semaphore() and added throwing exception
when sem initialisation fails just like in sem() for linux…

darwin.cc:  partially implemented update_cpu_usage() and
update_total_processes()

* Implements update_total_processes()

( Now it finds the correct number of tasks )

the changes in cmake file don’t change the functionality… It is only
comments.

In upcoming updates lua support may be enabled and the comments are
related to lua support.

* get_cpu_count() now conforms to newer sysctl code as suggested by Apple ( we use hw.logicalcpumax instead of hw.ncpus )   -->  The new implementation of get_cpu_count() finds the the max value of logical cores the mac could use on a boot.

update_total_processes() was patched to allow initialising only ONCE when conky runs the machHost and processorSet ( this could probably be implemented in a better way I guess though... )

* patch

* experimental support for get_top_info() and update_cpu_usage() :)

* going to patch stuff

* adds getting rss memory in get_top_info()

* fixes

* Couple things made more beautiful but too many things to fix ...

* Remove unneeded code from darwin_soundcard.h and keep only needed to
compile ( This way we are compatible to GPLv3, i think )

Include GPLv3 header in darwin.cc, darwin.h and darwin_soundcard.h

Add more beautiful and explanatory comments to ease the work of other
contributors… ( Mostly on things that don’t work! )

* Merged the macOS update_cpu_usage() implementation with the linux implementation but still it doesn't work as expected, plus, there are more memory related problems that will be fixed in newer release!

NOTE: It will be really good to see how functions are implemented on linux.cc for more complete implementation

* Now using a more linux-influenced implementation and dropping the old... ( only keeps mach stuff )
Needs some more work though to print accurate percentage! :)

* Add conky installer (.pkg) project

* Now gets thread count aswell! For now, we get this from update_total_processes... Also, removed the installer project because I need to learn more the software

* Properly get thread count!

- Patched core.cc to enable getting threads count on macOS!

- Cleanup in darwin.cc

* sort out some things in the code:

- running_threads_count is not the same as thread_count on macOS! There is actually a difference!
Correct a bit the code!

* Enable the if_mounted command and start implementing the check_mount function in darwin.cc

* Tighten things up

* This patch makes conky build easily and without patching on any supported macOS version!  The new flag introduced is a temporary solution for allowing conky to compile on other OS without tweaking the cmake files.  If you want to compile it with i18l support you will have to run the command: brew link gettext after you install gettext

* Update README to provide more complete info on building on macOS

* Fix

* patch check_mounted + SIP status

This commit:

- patches check_mounted function to match the implementation found in FreeBSD.cc! Now conky expects typing something like this:

conky -t '${if_mounted /Volumes/MacOS} ${endif}'

Please note that the correct way is "/Volumes/MacOS", not "/Volumes/MacOS/" ! You shouldnt put the backslash at the end... It will not work!

- Adds a new command called sip_status which you can use to make conky show System Integrity Protection related information such as if filesystem protection is enabled, if user approved kexts protection is enabled and more...

you can type conky -t '$sip_status' to  see what it does...

( I will most likely update some things later regarding sip_status and check_mounted )

* Further implement sip_status

sip_status now has different functionality!

If you give no arguments it shows whether SIP is enabled or disabled ( generally )
If you give argument ( takes only ONE ) you can specify which specific thing of SIP you want to show status for...

You need to pass 0, 1, ..., 9 to $sip_status as argument to print status for apple-internal, untrusted-kexts, and more...

Below you can see the list:

ARG:                   RESULT:
nothing --> print enabled / disabled
0   --> allow_apple_internal
1   --> allow_untrusted_kexts
2   --> allow_task_for_pid
3   --> allow_unrestricted_fs
4   --> allow_kernel_debugger
5   --> allow_unrestricted_dtrace
6   --> allow_unrestricted_nvram
7   --> allow_device_configuration
8   --> allow_any_recovery_os
9   --> allow_user_approved_kexts

* sip_status progress & if_up enabled

This commit adds the 'a' argument for $sip_status which checks if the SIP configuration is ok or it is likely to break in the future.

Also, enabled the $if_up command, but there are some problems with it...

* sip_status patches

- Updated code based on newest version of csrstat utility (v.1.8)
The 1.8 version fixes a problem in finding status of ALLOW_DEVICE_CONFIGURATION flag.

- Fixed a bug where we mistakenly printed 'disabled' even when SIP was enabled.

* Disable ncurses checks in a way that will allow compiling for other OSes! ( it was a really quick patch before )

* More changes in cmake file to make code prettier and more exact

* More cmake files cuteness

* work for supporting versions prior Sierra

This patch brings more compatibility with versions prior to Sierra.
The project as is nearly links on a 10.9.5 OSX installation.

- on versions prior Sierra clock_gettime() is not implemented thus we need to provide our own implementation for conky to work.  ( Currently we have minimal support, more studying needs to be done )

NOTE: In order to compile on versions as old as Mavericks you will need newer compilers because command line tools for 10.9.5 dont support some C++11 features... For this I donwloaded the commandline tools for Xcode 8.1 ( or 8 dont remember well ) and installed only the CommandLine Tools section with Pacifist!

( The OSX installer sees the OS as too old, so you need pacifist! )

* Oops

* $if_mounted ready

This patch removes the unneded print_mounted() function!
Also cleanup code.

* $if_up works

I think $if_up command works therefore remove the APPLE specific code in core.cc ( there wasnt anything different anyway ) and use the FreeBSD code.

Minor conky output changes in darwin.cc

* fix compatibility with Mavericks and before...

This update allows conky to be compiled on Mavericks and before by checking at compilation time what our build target is.

If it is Mavericks or lower, then cant use the csr_get_active_config func because it is not available.

On higher versions than Mavericks it works as before...

NOTE: For compiling on Mavericks or lower you will have to write 10.9 in CMAKE_OSX_DEPLOYMENT_TARGET when you run ccmake

* Added link for youtube video showing conky running on macOS

* Improvements

Minor improvements related to style
Removed unneeded free() calls

* Simplify Xcode configuration process! :)

* Removed update_cpu_usage() implementation

It was quite buggy so I removed it...

* Cleanup the source code

1. Bogus TODO comments have been deleted!
2. Started using DEBUG_MODE based printf
3. Explain some things better/cleanup

* Last small cleanup

The TODO in get_from_load_info() was unneeded.  Removed!

Also, DEBUG_MODE is enabled for now...

* update authors file

* Improve README

Make it more clean and easier to understand.

* Update README.md

small tweak

* Work for conforming with "Development" rules

1. Add to variables.xml documentation about the $sip_status variable.
2. Add sip_status variable to conkyrc.vim and nanorc to allow highlighting

3. the friends in darwin.cc is ambiguous,,, some are more than friends.

* First patch set that implements get_top_info()

:)

* Calculate cpu usage of all processes more efficiently.  (Now results match Activity Monitor's results a lot!!!)

More info about the get_top_info() implementation will come once I finish it! (soon)

* Cleanup patch!

o Move  a couple things to better places
o Rename get_sample() to get_cpu_sample() to allow to be used by different functions such as get_cpu_usage() ( this is a scene from the future... )
o Improve the way we get cpu usage for each process by passing the already created proc_taskinfo struct to the appropriate function instead of creating another one
	inside it!

* Correctly enable $running_processes variable

In our implementation update_top() doesn't calculate the count of running processes! We assign this functionality to the update_running_processes() function.

* Removed unneeded flag

This is not needed because we do not use update_top() for getting the number of running processes!

* Update README.md

* Update README.md

This adds support for TravisCL.

Though this will compile the project only on Linux it is a good sign to know if our port still can compile on Linux or we have broken things.  It seems like it can't but I suspect the problem existed before my patches.  I will investigate.

* First patch towards implementing #15

This patch a reworked get_top_info().  We now use the function get_top_info_for_kinfo_proc() to set the contents of each |process| struct.
Also, we calculate the total cpu usage and total process usage concurrently using GCD.

Aside from these we bring the function helper_get_proc_list() which makes the code simpler and cleaner.

* First fix for the algorithm that calculates % CPU usage of a process

The previous patch made the algorithm buggy.  It required more reentrant-safe functions.
Make calc_cpu_total_r() which is a more reentrant-safe reimplementation of the calc_cpu_total() function.
This is not the last commit, more are coming in the future.

* Previous commit wasn't pushed...

* Problems committing

* Make the code cleaner but break the algorithm again	#15

The algorithm doesn't work... It is a work in progress!
But this time we have merged the cpu_info and cpusample into one struct called cpusample
( I copied some variables from the linux implementation but they will probably be removed )

* Rework the code a bit / CPU usage % algorithm still doesn't work

Now get_from_load_info() is renamed to helper_update_threads_processes() and is called by both update_threads() and update_total_processes()
This makes the code nicer and removes the enum with the flags

* cleanup

remove unneeded functions, remove unneeded variables

* bugfix

* bugfix

* remove the whole get_top_info() code!

I will rework a lot this code so we can get rid of it.

* Work for #15

Now we use the ultimate solution for calculating % usage of CPU of a process!

Check the #15 Issue for information about this patch!

* Quick memory leak fix & some patches for the get_top_info algorithm

* quick patch for semaphore class

* Update the comments

* For consistency

* temp

* Revert "Merge branch 'master' into update_cpu_usage"

This reverts commit 7267a515c40d54b85107e51016703e6c10f3183e, reversing
changes made to 2190ff0b51463c12c61b3357cf846b8e705ebeb4.

* Revert "Revert "Merge branch 'master' into update_cpu_usage""

This reverts commit 692bd27a3adb2fe7027d65932467a140e42cc7bc.

* Partially implement the overall % CPU usage

* bug fix: I meant procs and threads!

* make the code better part1

* cleanup

* Stabilise the values of get_cpu_sample(). Affects get_top_info() and update_cpu_usage() ( fixes #13 and #15 )

For some reason the code that used host_statistics() function didn't produced bad values quite often.  Replaced the function with host_processor_info() and changed the algorithm
and now the values are correct!

This affects the get_top_info() and update_cpu_usage() functions which wouldn't work correctly until now.

* Finish the optimised version of get_top_info()

Fixes #15

* Quick fix for #16

Probably I will come up with a different location for get_cpu_count() because I want to conform to linux implementation.
Also, the memory leak I am mentioning in get_cpu_count() may not actually exist, as I suspected in the back of my head.

* Strictness

* Cleanup ConkyPlatformChecks.cmake

Cleanup the quick patch code for Lua.

* Add warning to README

If you are using old version of cmake, update it.  It will probably have problems when trying to locate lua.

* More cleanup

* Fix identation

This simplifies the diff.

Also, note that by merging the new code for checking for NCURSES we acheive better compatibility and easy build process

* Remove mixer related patches and files

With the newest patches from upstream, cmake checks if the header soundcard.h exists on the system.

If it doesn't exist (in the case of macOS for example) all mixer-related variables are disabled.

* Changes for using as submodule for ConkyX

* Fixes

* Implement get_freq

This implements #11
Though it doesn't support getting the **current** cpu frequency.

I haven't found a way to do it on macOS but i guess it can be done using a kernel extension. I may come back to this again in the future

* First work for correcting mem stats #6

Incorporate the update_pages_stolen() function and all of its dependencies.

I will see if I can patch the code in order to avoid license problems

* Work for #6

Now we follow the way apple's top works and not Activity Monitor.

For this reason we find different values.  But correct based on top.

* cleanup for #6

* bug fix 1

* cleanup

* hmm sorry

* More cleanup

- Move the libtop_tsamp_t object to darwin.cc.

- Remove unneeded member variables.

* A bit documentation

* Implement secondary memory stats #6

Implement memwithbuffers, memeasyfree and memfree (which isn't secondary)

* Quit update_meminfo if libtop_tsamp_update_vm_stats() failed

* Update README.md

Revert to original conky readme
Move all macOS related information to the Wiki: https://github.com/Conky-for-macOS/conky-for-macOS/wiki

* Alot junk slipped in too!

* Merge net_stats branch

For now, I have only tested up / down bytes count on en0, and it works.

This is for #14

* Corrections

- Fix License headers in darwin* files
- Remove ConkyX entry from .gitignore which slipped into from the "forConkyX" branch which was used for another project ... ConkyX.
- Cleanup top.h  (I will request the changes in a pull request finally)

* Fix identation and cleanup

* identation-fixes part1

* Try to fix problem compiling on linux

Improve checks for headers in ConkyPlatformChecks.cmake to amend the problem;
I mistakenly thought that statfs64 wasn't available in sys/statfs.h in macOS thus I tried to add platform specific code.  Though, I add the checks in the wrong place and also messed up linux-specific code by replacing checks_include sys/statfs with check_symbol_exists statfs64

* attemp to completely fix linux problem!
This commit is contained in:
npyl 2018-05-07 14:27:32 +03:00 committed by Brenden Matthews
parent e0990f3e7d
commit b20d83b747
21 changed files with 1852 additions and 52 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
*~
.*.swp
Doxyfile

View File

@ -243,6 +243,9 @@ nathanj439 <nathanj439 at users dot sourceforge dot net>
Nikos Ntarmos <ntarmos at users dot sourceforge dot net>
FreeBSD total memory patch
Nikos Pylarinos <n dot pylarinos at hotmail dot com>
macOS support
norsetto <norsetto at ubuntu dot com>
fix SIGUSR1/SIGHUP segfault

0
README.md Normal file → Executable file
View File

View File

@ -51,11 +51,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
set(OS_HAIKU true)
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(OS_DARWIN true)
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY
AND NOT OS_SOLARIS AND NOT OS_HAIKU)
AND NOT OS_SOLARIS AND NOT OS_HAIKU AND NOT OS_DARWIN)
message(FATAL_ERROR "Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome.")
endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY
AND NOT OS_SOLARIS AND NOT OS_HAIKU)
AND NOT OS_SOLARIS AND NOT OS_HAIKU AND NOT OS_DARWIN)
include(FindThreads)
find_package(Threads)
@ -63,9 +67,15 @@ find_package(Threads)
set(conky_libs ${CMAKE_THREAD_LIBS_INIT})
set(conky_includes ${CMAKE_BINARY_DIR})
add_definitions(-D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L) # Standard definitions
set(CMAKE_REQUIRED_DEFINITIONS
"${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L")
#
# On Darwin _POSIX_C_SOURCE must be >= __DARWIN_C_FULL for asprintf to be enabled!
# Thus disable this and _LARGEFILE64_SOURCE isnt needed, it is already used on macOS.
#
if(NOT OS_DARWIN)
add_definitions(-D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L) # Standard definitions
set(CMAKE_REQUIRED_DEFINITIONS
"${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L")
endif(NOT OS_DARWIN)
if(OS_DRAGONFLY)
set(conky_libs ${conky_libs} -L/usr/pkg/lib)

View File

@ -36,11 +36,20 @@ check_function_exists(strndup HAVE_STRNDUP)
check_symbol_exists(pipe2 "unistd.h" HAVE_PIPE2)
check_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
check_symbol_exists(statfs64 "sys/statfs.h" HAVE_STATFS64)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
check_symbol_exists(statfs64 "sys/mount.h" HAVE_STATFS64)
else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
check_symbol_exists(statfs64 "sys/statfs.h" HAVE_STATFS64)
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
AC_SEARCH_LIBS(clock_gettime "time.h" CLOCK_GETTIME_LIB "rt")
if(NOT DEFINED CLOCK_GETTIME_LIB)
message(FATAL_ERROR "clock_gettime not found.")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(FATAL_ERROR "clock_gettime not found.")
endif(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
else(NOT DEFINED CLOCK_GETTIME_LIB)
set(HAVE_CLOCK_GETTIME 1)
endif(NOT DEFINED CLOCK_GETTIME_LIB)
set(conky_libs ${conky_libs} ${CLOCK_GETTIME_LIB})
@ -80,11 +89,15 @@ if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
set(conky_libs ${conky_libs} -lnetwork -lintl)
endif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(OS_DARWIN true)
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY
AND NOT OS_SOLARIS AND NOT OS_HAIKU)
AND NOT OS_SOLARIS AND NOT OS_HAIKU AND NOT OS_DARWIN)
message(FATAL_ERROR "Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome.")
endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY
AND NOT OS_SOLARIS AND NOT OS_HAIKU)
AND NOT OS_SOLARIS AND NOT OS_HAIKU AND NOT OS_DARWIN)
# Check for soundcard header
if(OS_LINUX)
@ -100,6 +113,14 @@ if(BUILD_I18N AND OS_DRAGONFLY)
set(conky_libs ${conky_libs} -lintl)
endif(BUILD_I18N AND OS_DRAGONFLY)
if(BUILD_I18N AND OS_DARWIN)
set(conky_libs ${conky_libs} -lintl)
endif(BUILD_I18N AND OS_DARWIN)
if(BUILD_NCURSES AND OS_DARWIN)
set(conky_libs ${conky_libs} -lncurses)
endif(BUILD_NCURSES AND OS_DARWIN)
if(BUILD_MATH)
set(conky_libs ${conky_libs} -lm)
endif(BUILD_MATH)

View File

@ -40,6 +40,8 @@
#cmakedefine HAVE_PIPE2 1
#cmakedefine HAVE_O_CLOEXEC 1
#cmakedefine HAVE_CLOCK_GETTIME 1
#cmakedefine BUILD_X11 1
#cmakedefine OWN_WINDOW 1

View File

@ -3744,6 +3744,41 @@
are supported, mbox type will return -1.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>sip_status</option>
</command>
<option>(switch)</option>
</term>
<listitem>Prints info regarding System Integrity Protection (SIP) on macOS.
Specifically, prints SIP status (enabled / disabled) if no switch is
provided OR status of specific SIP feature if a switch is provided.
Below are the allowed switches: (each switch is a char)
SWITCH-----------------------RESULT-------------------------------
0 allows apple-internal? YES/NO
1 allows untrusted-kexts? YES/NO
2 allows task-for-pid? YES/NO
3 allows unrestricted-fs? YES/NO
4 allows kernel-debugger? YES/NO
5 allows unrestricted-dtrace? YES/NO
6 allows unrestricted-nvram? YES/NO
7 allows device-configuration? YES/NO
8 allows any-recovery-os? YES/NO
9 allows user-approved-kexts? YES/NO
a uses unsupported configuration?
If yes, prints "unsupported configuration, beware!"
Else, prints "configuration is ok".
------------------------------------------------------------------
EXAMPLE:
conky -t '${sip_status}' # print SIP status
conky -t '${sip_status 0}' # print allows apple-internal? Yes or No?
NOTES: exists only for macOS version of conky and works on any macOS
version (even the ones prior El Capitan where SIP was first introduced).
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>

View File

@ -11,7 +11,7 @@ color green "\<(alignment|append_file|background|border_inner_margin|border_oute
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>"
## Variables
color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|distribution|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|format_time|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|ical|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_pa_sink_muted|if_xmms2_connected|image|imap_messages|imap_unseen|ioscheduler|irc|journal|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|memwithbuffers|membar|memwithbuffersbar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|mysql|nameserver|new_mails|nodename|nodename_short|no_update|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pa_sink_volume|pa_sink_volumebar|pa_sink_description|pa_card_name pa_card_active_profile|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_nice|pid_openfiles|pid_parent|pid_priority|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_threads|pid_thread_list|pid_time_kernelmode|pid_time_usermode|pid_time|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_read|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|pid_write|platform|pop3_unseen|pop3_used|processes|read_tcp|read_udp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|stock|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_ping|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>"
color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|distribution|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|format_time|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|ical|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_pa_sink_muted|if_xmms2_connected|image|imap_messages|imap_unseen|ioscheduler|irc|journal|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|memwithbuffers|membar|memwithbuffersbar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|mysql|nameserver|new_mails|nodename|nodename_short|no_update|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pa_sink_volume|pa_sink_volumebar|pa_sink_description|pa_card_name pa_card_active_profile|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_nice|pid_openfiles|pid_parent|pid_priority|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_threads|pid_thread_list|pid_time_kernelmode|pid_time_usermode|pid_time|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_read|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|pid_write|platform|pop3_unseen|pop3_used|processes|read_tcp|read_udp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|sip_status|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|stock|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_ping|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>"
color brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"

View File

@ -50,7 +50,7 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV
syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write distribution downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font format_time forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume ical iconv_start iconv_stop if_pa_sink_muted if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen ioscheduler irc journal kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem memwithbuffers membar memwithbuffersbar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol mysql nameserver new_mails nodename nodename_short no_update nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pa_sink_volume pa_sink_volumebar pa_sink_description pa_card_name pa_card_active_profile pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_nice pid_openfiles pid_parent pid_priority pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_threads pid_thread_list pid_time_kernelmode pid_time_usermode pid_time pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_read pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte pid_write platform pop3_unseen pop3_used processes read_tcp read_udp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr stock swap swapbar swapfree swapmax swapperc sysname tab tail tcp_ping tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write distribution downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font format_time forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume ical iconv_start iconv_stop if_pa_sink_muted if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen ioscheduler irc journal kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem memwithbuffers membar memwithbuffersbar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol mysql nameserver new_mails nodename nodename_short no_update nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pa_sink_volume pa_sink_volumebar pa_sink_description pa_card_name pa_card_active_profile pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_nice pid_openfiles pid_parent pid_priority pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_threads pid_thread_list pid_time_kernelmode pid_time_usermode pid_time pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_read pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte pid_write platform pop3_unseen pop3_used processes read_tcp read_udp replied_mails rss running_processes running_threads scroll seen_mails shadecolor sip_status smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr stock swap swapbar swapfree swapmax swapperc sysname tab tail tcp_ping tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url
hi def link ConkyrcComment Comment
hi def link ConkyrcSetting Keyword

View File

@ -80,6 +80,11 @@ if(OS_HAIKU)
set(optional_sources ${optional_sources} ${haiku})
endif(OS_HAIKU)
if(OS_DARWIN)
set(darwin darwin.cc)
set(optional_sources ${optional_sources} ${darwin})
endif(OS_DARWIN)
# Optional sources
if(HAVE_SOME_SOUNDCARD_H)
set(mixer mixer.cc)

View File

@ -59,6 +59,8 @@
#include "dragonfly.h"
#elif defined(__OpenBSD__)
#include "openbsd.h"
#elif defined(__APPLE__) && defined(__MACH__)
#include "darwin.h" // strings.h
#endif
#include "update-cb.hh"

View File

@ -218,6 +218,30 @@ struct information {
#endif /* BUILD_X11 */
short kflags; /* kernel settings, see enum KFLAG */
#if defined(__APPLE__) && defined(__MACH__)
/* System Integrity Protection related */
struct csr_config_flags {
bool csr_allow_untrusted_kexts;
bool csr_allow_unrestricted_fs;
bool csr_allow_task_for_pid;
bool csr_allow_kernel_debugger;
bool csr_allow_apple_internal;
bool csr_allow_unrestricted_dtrace;
bool csr_allow_unrestricted_nvram;
bool csr_allow_device_configuration;
bool csr_allow_any_recovery_os;
bool csr_allow_user_approved_kexts;
};
/* SIP typedefs */
typedef csr_config_flags csr_config_flags_t;
typedef uint32_t csr_config_t;
/* SIP variables */
csr_config_t csr_config;
csr_config_flags_t csr_config_flags;
#endif /* defined(__APPLE__) && defined(__MACH__) */
};
class music_player_interval_setting: public conky::simple_config_setting<double> {

View File

@ -115,6 +115,8 @@
#include "dragonfly.h"
#elif defined(__OpenBSD__)
#include "openbsd.h"
#elif defined(__APPLE__) && defined(__MACH__)
#include "darwin.h"
#endif
#include <string.h>
@ -542,7 +544,7 @@ struct text_object *construct_text_object(char *s, const char *arg,
}
obj->callbacks.print = get_powerbook_batt_info;
#endif /* __linux__ */
#if (defined(__FreeBSD__) || defined(__linux__) || defined(__DragonFly__))
#if (defined(__FreeBSD__) || defined(__linux__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__)))
END OBJ_IF_ARG(if_up, 0, "if_up needs an argument")
parse_if_up_arg(obj, arg);
obj->callbacks.iftest = &interface_up;
@ -954,6 +956,17 @@ struct text_object *construct_text_object(char *s, const char *arg,
obj->data.s = strndup(arg, text_buffer_size.get(*state));
obj->callbacks.iftest = &if_running_iftest;
obj->callbacks.free = &gen_free_opaque;
#elif defined(__APPLE__) && defined(__MACH__)
END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
obj->data.s = strndup(arg, text_buffer_size.get(*state));
obj->callbacks.iftest = &check_mount;
obj->callbacks.free = &gen_free_opaque;
/* System Integrity Protection */
END OBJ(sip_status, &get_sip_status)
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state));
obj->callbacks.print = &print_sip_status;
obj->callbacks.free = &gen_free_opaque;
#else
END OBJ_IF_ARG(if_running, 0, "if_running needs an argument")
char buf[text_buffer_size.get(*state)];
@ -1251,6 +1264,13 @@ struct text_object *construct_text_object(char *s, const char *arg,
#if defined(__DragonFly__)
END OBJ(running_processes, &update_top)
obj->callbacks.print = &print_running_processes;
#elif (defined(__APPLE__) && defined(__MACH__))
END OBJ(running_processes, &update_running_processes)
obj->callbacks.print = &print_running_processes;
END OBJ(threads, &update_threads)
obj->callbacks.print = &print_threads;
END OBJ(running_threads, &update_running_threads)
obj->callbacks.print = &print_running_threads;
#else
END OBJ(running_processes, &update_running_processes)
obj->callbacks.print = &print_running_processes;

1480
src/darwin.cc Normal file

File diff suppressed because it is too large Load Diff

59
src/darwin.h Normal file
View File

@ -0,0 +1,59 @@
/*
* Conky, a system monitor, based on torsmo
*
* Any original torsmo code is licensed under the BSD license
*
* All code written since the fork of torsmo is licensed under the GPL
*
* Please see COPYING for details
*
* Copyright (c) 2018, npyl <n.pylarinos@hotmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef DARWIN_H
#define DARWIN_H
#include <sys/param.h>
#include <sys/mount.h>
#include <strings.h>
#include <stdio.h>
/*
* on versions prior to Sierra clock_gettime is not implemented.
*/
#ifndef HAVE_CLOCK_GETTIME
/* only CLOCK_REALTIME and CLOCK_MONOTONIC are emulated */
#ifndef CLOCK_REALTIME
# define CLOCK_REALTIME 0
#endif
#ifndef CLOCK_MONOTONIC
# define CLOCK_MONOTONIC 1
#endif
int clock_gettime(int clock_id, struct timespec *ts);
#endif /* ifndef HAVE_CLOCK_GETTIME */
int update_running_threads(void);
int get_entropy_avail(unsigned int *);
int get_entropy_poolsize(unsigned int *);
/* System Integrity Protection */
int get_sip_status(void);
void print_sip_status(struct text_object *obj, char *p, int p_max_size);
#endif /*DARWIN_H*/

64
src/darwin_sip.h Normal file
View File

@ -0,0 +1,64 @@
/*
* Conky, a system monitor, based on torsmo
*
* Any original torsmo code is licensed under the BSD license
*
* All code written since the fork of torsmo is licensed under the GPL
*
* Please see COPYING for details
*
* Copyright (c) 2018, npyl <n.pylarinos@hotmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
//
// Defines for System Integrity Protection monitoring
// based on csrstat tool by Pike R. Alpha. https://github.com/Piker-Alpha/csrstat
//
#ifndef DARWIN_SIP_H
#define DARWIN_SIP_H
/* Rootless configuration flags */
#define CSR_ALLOW_UNTRUSTED_KEXTS (1 << 0) // 1
#define CSR_ALLOW_UNRESTRICTED_FS (1 << 1) // 2
#define CSR_ALLOW_TASK_FOR_PID (1 << 2) // 4
#define CSR_ALLOW_KERNEL_DEBUGGER (1 << 3) // 8
#define CSR_ALLOW_APPLE_INTERNAL (1 << 4) // 16
#define CSR_ALLOW_UNRESTRICTED_DTRACE (1 << 5) // 32
#define CSR_ALLOW_UNRESTRICTED_NVRAM (1 << 6) // 64
#define CSR_ALLOW_DEVICE_CONFIGURATION (1 << 7) // 128
#define CSR_ALLOW_ANY_RECOVERY_OS (1 << 8) // 256
#define CSR_ALLOW_UNAPPROVED_KEXTS (1 << 9) // 512
#define CSR_VALID_FLAGS (CSR_ALLOW_UNTRUSTED_KEXTS | \
CSR_ALLOW_UNRESTRICTED_FS | \
CSR_ALLOW_TASK_FOR_PID | \
CSR_ALLOW_KERNEL_DEBUGGER | \
CSR_ALLOW_APPLE_INTERNAL | \
CSR_ALLOW_UNRESTRICTED_DTRACE | \
CSR_ALLOW_UNRESTRICTED_NVRAM | \
CSR_ALLOW_DEVICE_CONFIGURATION | \
CSR_ALLOW_ANY_RECOVERY_OS | \
CSR_ALLOW_UNAPPROVED_KEXTS)
/* Syscalls */
// mark these symbols as weakly linked, as they may not be available
// at runtime on older OS X versions.
extern "C" {
int csr_get_active_config(information::csr_config_t* config) __attribute__((weak_import));
};
#endif

View File

@ -45,6 +45,8 @@
#include "solaris.h"
#elif defined(__HAIKU__)
#include "haiku.h"
#elif defined(__APPLE__) && defined(__MACH__)
#include "darwin.h"
#endif
struct _entropy {

View File

@ -54,12 +54,15 @@
#include "dragonfly.h"
#elif defined(__HAIKU__)
#include "haiku.h"
#elif defined(__APPLE__) && defined(__MACH__)
#include "darwin.h"
#endif
#if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && \
!defined (__OpenBSD__) && !defined(__FreeBSD__) && \
!defined(__DragonFly__) && !defined(__sun) && !defined(__HAIKU__)
!defined(__DragonFly__) && !defined(__sun) && !defined(__HAIKU__) && \
!(defined(__APPLE__) && defined(__MACH__))
#include <mntent.h>
#endif
@ -156,7 +159,7 @@ void get_fs_type(const char *path, char *result)
{
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || \
defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__HAIKU__)
defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__))
struct statfs64 s;
if (statfs64(path, &s) == 0) {

View File

@ -57,7 +57,13 @@ namespace lua {
lua_pushstring(l, e.what());
}
catch(...) {
lua_pushstring(l, ptr->__cxa_exception_type()->name());
#if defined(__APPLE__) && defined(__MACH__)
//lua_pushstring(l, ptr->__cxa_exception_type()->name());
printf("%s: FIXME: no member named '__cxa_exception_type' in 'std::exception_ptr' \n", __func__);
lua_pushstring(l, "FIXME: in luamm.cc");
#else
lua_pushstring(l, ptr->__cxa_exception_type()->name());
#endif
}
return 1;
}

View File

@ -29,47 +29,109 @@
#include <cstring>
#include <stdexcept>
#if defined(__APPLE__) && defined(__MACH__)
/*
* On Darwin, unnamed semaphores are not supported!
* The only close equivalent to unnamed semaphores is using
* GCD!
*/
#include <dispatch/dispatch.h>
class semaphore {
dispatch_semaphore_t sem;
semaphore(const semaphore &) = delete;
semaphore& operator=(const semaphore &) = delete;
public:
semaphore(unsigned int value = 0) throw(std::logic_error)
{
sem = dispatch_semaphore_create(value);
if (!sem)
throw std::logic_error(strerror(errno));
}
~semaphore() throw()
{
dispatch_release(sem);
}
void post() throw(std::overflow_error)
{
dispatch_semaphore_signal(sem);
}
void wait() throw()
{
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
}
bool trywait() throw()
{
/* XXX Quick patch */
#define DISPATCH_EAGAIN 49
int ret = dispatch_semaphore_wait(sem, DISPATCH_TIME_NOW);
while (ret > 0)
{
if(ret == DISPATCH_EAGAIN)
return false;
else if(errno != EINTR)
abort();
}
return true;
}
};
#else
#include <semaphore.h>
class semaphore {
sem_t sem;
sem_t sem;
semaphore(const semaphore &) = delete;
semaphore& operator=(const semaphore &) = delete;
semaphore(const semaphore &) = delete;
semaphore& operator=(const semaphore &) = delete;
public:
semaphore(unsigned int value = 0) throw(std::logic_error)
{
if(sem_init(&sem, 0, value))
throw std::logic_error(strerror(errno));
}
semaphore(unsigned int value = 0) throw(std::logic_error)
{
if(sem_init(&sem, 0, value))
throw std::logic_error(strerror(errno));
}
~semaphore() throw()
{ sem_destroy(&sem); }
~semaphore() throw()
{ sem_destroy(&sem); }
void post() throw(std::overflow_error)
{
if(sem_post(&sem))
throw std::overflow_error(strerror(errno));
}
void post() throw(std::overflow_error)
{
if(sem_post(&sem))
throw std::overflow_error(strerror(errno));
}
void wait() throw()
{
while(sem_wait(&sem)) {
if(errno != EINTR)
abort();
}
}
void wait() throw()
{
while(sem_wait(&sem)) {
if(errno != EINTR)
abort();
}
}
bool trywait() throw()
{
while(sem_trywait(&sem)) {
if(errno == EAGAIN)
return false;
else if(errno != EINTR)
abort();
}
return true;
}
bool trywait() throw()
{
while(sem_trywait(&sem)) {
if(errno == EAGAIN)
return false;
else if(errno != EINTR)
abort();
}
return true;
}
};
#endif /* defined(__APPLE__) && defined(__MACH__) */
#endif

View File

@ -97,6 +97,7 @@ struct process {
unsigned long previous_user_time;
unsigned long previous_kernel_time;
unsigned long total_cpu_time;
unsigned long previous_total_cpu_time;
unsigned long long vsize;
unsigned long long rss;
#ifdef BUILD_IOSTATS