+++ /dev/null
-Make*
-auto*
-conf*
-aclocal.m4
-*.o
-*bar
-temp_dir/
-src/.deps/
-*.in
-*.in~
-stamp-h1
-*.txt
-src/pinky_curses
-
-
-
-
-
-
-
-
-
-
-
-!pkg/FreeBSD/Makefile
+++ /dev/null
-dwm
-
-![](img/pic.png)
-
-xmonad
-
-![](img/pic5.png)
-
-![](img/pic7.png)
-
-ncurses
-
-![](img/pic6.png)
-
-
-Gather some system information and show it in this statusbar program, not tied to any Window Manager, terminal multiplexer, etc.
-
-Please note that the program won't detect fans connected via molex connetor(s) or external fan controller. Also I have not tested it with fan splitter(s) either.
-
-The program is smart enough to detect whether some of your fan(s) blades are spinning, or the particular fan have been removed. Hold down some of your fan blades and you'll see that the program won't include this fan and it's RPM, release the blades and you'll see the fan and it's RPM in the statusbar. Try simulating real fan hardware failure by holding down all system fan blades and watch what the program will show you, just try not to slice your cheesy fingers open in the process.
-
-If you compile your kernel from source code make sure to include your cpu and motherboard sensors as **modules** and not inlined.
-
-**Just an example if you use BSD - acpi/aibs, coretemp/amdtemp.**
-
-![](img/cpu-temp.png)
-
-![](img/mobo-temp.png)
-
----
-
-## Bandwidth measurment
-
-pinky-bar supplies bandwitdh/network throughput measurment to satisfy those users that pay for overpriced 3G/mobile internet, and want to monitor every single megabit/megabyte.
-
-## Program options
-
-The order of supplied options will dictate how, where and what system information to be shown.
-
-| short option | long option | Descrtiption |
-|--------------|-------------|--------------------------------------------------------------------|
-| -M | --mpd | The song filename |
-| -W | --mpdtrack | The song track name (not available in cmus) |
-| -x | --mpdartist | The song artist(s) name(s) |
-| -X | --mpdtitle | The song title |
-| -y | --mpdalbum | The song album name |
-| -Y | --mpddate | The song date |
-| -c | --cpu | The current cpu load (summed up all cores/threads) |
-| -L | --coresload | Show the load regarding each individual cpu core/thread |
-| -T | --cputemp | The current cpu temperature |
-| -C | --cpuspeed | Show your maximum cpu clock speed in MHz, regardless of the used governor. Uses assembly. |
-| -I | --cpuinfo | Detect your CPU vendor, stepping, family, clflush, l1/l2 cache and line size, physical cores, physical and virtual bits. Uses assembly. |
-| -r | --ramperc | The used ram in percentage |
-| -J | --ramtotal | The total ram |
-| -K | --ramfree | The free ram |
-| -l | --ramshared | The shared ram |
-| -o | --rambuffer | The buffer ram (not available in OpenBSD) |
-| -s | --driveperc | The used drive storage in percentage |
-| -n | --drivetotal| The total drive storage |
-| -N | --drivefree | The free drive storage |
-| -O | --driveavail| The available drive storage (total - used) |
-| -g | --battery | The remaining battery charge |
-| -z | --dvdstr | The vendor and model name of your cdrom/dvdrom |
-| -S | --statio | Read and written MBs to the drive so far [argument - sda] |
-| -p | --packages | The number of installed packages |
-| -P | --kernsys | The kernel name |
-| -q | --kernode | The network node hostname |
-| -Q | --kernrel | The kernel release |
-| -R | --kernver | The kernel version |
-| -u | --kernarch | The machine architecture |
-| -k | --kernel | Combined kernel name and version |
-| -U | --uptime | The system uptime |
-| -w | --loadavg | The system average load for past 1, 5 and 15 minutes |
-| -v | --voltage | The system voltage |
-| -f | --fans | All system fans and their speed in RPM |
-| -m | --mobo | Show the motherboard name and vendor |
-| -d | --mobotemp | The motherboard temperature |
-| -V | --volume | The sound volume |
-| -t | --time | The current time |
-| -a | --ipaddr | The local ip address [argument - eth0] |
-| -b | --bandwitdh | The consumed internet bandwidth so far [argument - eth0] |
-| -i | --iface | The current download and upload speed [argument - eth0] |
-| -A | --ipmac | The NIC mac address [argument - eth0] |
-| -B | --ipmask | The NIC subnet mask [argument - eth0] |
-| -D | --ipcast | The NIC broadcast address [argument - eth0] |
-| -E | --iplookup | Mini website IP lookup [website argument - google.com] |
-
-Be aware of the options that mention **Uses assembly** are tested only on AMD and Intel CPUs (starting from pentium 4 onwards).
-
-The following options are available only in Linux:
-
-| short option | long option | Descrtiption |
-|--------------|-------------|--------------------------------------------------------------------|
-| -F | --drivemodel| The vendor name of your drive [argument - sda] |
-| -G | --nicinfo | The NIC vendor and model [argument - eth0] |
-| -h | --nicdrv | The NIC driver [argument - eth0] |
-| -H | --nicver | The NIC version [argument - eth0] |
-| -e | --iplink | The NIC link speed (useful for wireless/wifi) [argument - eth0] |
-| -j | --nicfw | The NIC firmware [argument - eth0] |
-
-The following options are available only to FreeBSD and OpenBSD:
-
-| short option | long option | Descrtiption |
-|--------------|-------------|--------------------------------------------------------------------|
-| -j | --nicgw | The NIC gateway address [argument - re0] |
-| -Z | --swapused | The used drive swap in MB |
-| -F | --swaperc | The used drive swap in percentage |
-| -h | --swaptotal | The total drive swap |
-| -H | --swapavail | The available drive swap (total - used) |
-
-The following options are available only in OpenBSD:
-
-| short option | long option | Descrtiption |
-|--------------|-------------|--------------------------------------------------------------------|
-| -l | --ramused | The used ram in MB |
-
----
-
-## GNU Build System (configure) options
-
-Before the source code is passed to the compiler, you can enable/disable the following **configure** options
-that will increase/reduce the number of dependencies required to compile the program.
-
-It's up to you to decide which features suit you best.
-
-| To include | Not to include | Descrtiption |
-|----------------|---------------------|--------------------------------------------------------------------------------------------|
-| --with-x11 | --without-x11 | Enable it if you are using dwm. |
-| --with-alsa | --without-alsa | To get the sound volume level. |
-| --with-oss | --without-oss | To get the sound volume level in \*BSD. |
-| --with-net | --without-net | Enable the internet related options. |
-| --with-pci | --without-pci | To get the NIC vendor and model in linux |
-| --with-dvd | --without-dvd | To get the cdrom/dvdrom vendor and model |
-| --with-sensors | --without-sensors | Alternative way to get the sensors values (linux only) |
-| --with-apm | --without-apm | APM power and resource management for laptops (FreeBSD only) |
-| --with-ncurses | --without-ncurses | Output the data to the terminal using the ncurses library, can be colorized |
-| --with-colours | --without-colours | Colorize the output data. |
-| icons=/tmp | | xbm icons that can be used by dzen2 for example. Discarded when **--with-x11** is used |
-| --with-mpd | --without-mpd | To see the currently played song name (if any). |
-| --prefix=/tmp | | The directory where the program will be installed |
-| mobo\_sensor='dev.aibs.0' | | FreeBSD motherboard sensor module name to use in the sysctl calls. Read the FreeBSD installation below |
-| cpu\_sensor='dev.cpu.0.temperature' | | FreeBSD cpu temperature module name to use in the sysctl calls . Read the FreeBSD installation below |
-
-By default, if **no** options are passed, the program will be compiled with/without:
-
-```bash
---without-alsa --without-x11 --without-mpd --with-colours --with-net --with-pci --without-dvd --without-sensors --without-ncurses
-```
-
-Affects only FreeBSD users with laptops, **--without-apm** will compile the program with acpi support to obtain the current battery life.
-
-**--without-mpd** will compile the program with cmus support, the options syntax stays as is.
-
-The pci and sensors configure options will be discarded in \*BSD. If you supplied **--with-alsa** and **--with-oss** or used the port package with the ncurses dialogue, alsa will have higher precedence over OSS. By default the port package will have OSS selected and alsa unselected.
-
-Affects only linux, **--with-pci** and or **--with-sensors** will substitute -O0 flag to mitigate bugs in GCC caused by -O2 optimizations. -O0 will optimize the compiled binary for file size, while -O2 will optimize it for speed. So don't be shocked to find out that **--without-pci --without-sensors** will cause the compiled binary to double it's size. If things doesn't improve with upcomining GCC releases I will temporary drop -O2.
-
----
-
-## Installation for dwm
-
-```bash
-bash bootstrap distro
-./configure --prefix=$HOME/.cache --with-x11 --with-alsa
-make
-make install
-```
-
-To see the currently played song name add **--with-mpd** to configure.
-
-To disable the colours you can add **--without-colours** to configure.
-
-Put the following in your **xinitrc** or the script used to start dwm.
-
-```bash
-# Execute the "statusbar" program every 5 secs
-while true; do
- # scroll a few lines up to see the rest options
- "$HOME/.cache/bin/pinkybar" -LTrspkvfmdVt
- sleep 5
-done &
-```
-
-## Installation for xmonad (or other WM)
-
-```bash
-# Copy the xbm icons
-mkdir -p --mode=700 $HOME/.xmonad/icons
-cp -r xbm_icons/*.xbm $HOME/.xmonad/icons
-
-# rename the program
-sed -i 's/pinkybar/xmonadbar/g' bootstrap
-
-bash bootstrap distro
-
-# disable X11, point the location to the icons
-./configure --prefix=$HOME/.cache --without-x11 --with-alsa icons=$HOME/.xmonad/icons
-
-# compile 'n install
-make
-make install
-```
-
-To see the currently played song name add **--with-mpd** to configure.
-
-Put the following in your **xinitrc** or the script used to start xmonad.
-
-```bash
-# Execute the "statusbar" program every 2 secs
-while true; do
- # scroll a few lines up to see the rest options
- "$HOME/.cache/bin/xmonadbar" -LTrspkvfmdVt
- sleep 2
-done | dzen2 -w 1800 -x 130 -ta r -fn '-*-dejavusans-*-r-*-*-11-*-*-*-*-*-*-*' &
-```
-
-## Installation in FreeBSD
-
-FreeBSD has no other way than using the module specific convention to query sysctl and obtain data from the sensors. Maintaining a list with all the possible module names and performing expensive sysctl calls in a loop to determine that X module is loaded into your system is no-go. Be prepared to spend a minute or two to find out some system information.
-
-Let's say you are using dwm:
-
-Determine the motherboard sensor module name.
-
-```bash
-sysctl -a|grep 'aibs'
-
-dev.aibs.0.volt.0: 1356 850 1600
-dev.aibs.0.volt.1: 3344 2970 3630
-dev.aibs.0.volt.2: 5040 4500 5500
-dev.aibs.0.volt.3: 12278 10200 13800
-dev.aibs.0.temp.0: 39.0C 60.0C 95.0C
-dev.aibs.0.temp.1: 38.0C 45.0C 75.0C
-dev.aibs.0.fan.0: 1053 600 7200
-dev.aibs.0.fan.1: 1053 600 7200
-```
-
-Copy only 'dev.MODULE.NUMBER' (if there is any number at all) and paste it into the **mobo\_sensor** option below.
-
-Do the same for your cpu temperature, copy and paste the variable as is. **dev.cpu.0.temperature** below is provied as example.
-
-```bash
-bash bootstrap freebsd
-./configure --prefix=$HOME/.cache --with-x11 --without-alsa --with-oss mobo_sensor='dev.aibs.0' cpu_sensor='dev.cpu.0.temperature'
-make
-make install
-```
-
-Send a request to the FreeBSD mail list and request the OpenBSD sensors API to be ported.
-
-
-## Installation in OpenBSD
-
-Before even executing the **bootstrap** script, you'll have to do this:
-
-```bash
-# To detect the newer compiler that you are
-# about to install
-sed -i 's/#AC_PROG_CC(/AC_PROG_CC(/g' bootstrap
-
-ls /usr/local/bin/automake-*
-ls /usr/local/bin/autoconf-*
-
-# Then replace the numbers below
-export AUTOCONF_VERSION=2.69
-export AUTOMAKE_VERSION=1.15
-
-# Your call, gcc or llvm ?
-pkg_add gcc
-```
-
-## pinky curses installation
-
-```bash
-# rename the program
-sed -i 's/pinkybar/randombar/g' bootstrap
-
-bash bootstrap distro
-
-# disable X11
-./configure --prefix=$HOME/.cache --without-x11 --with-alsa --with-colours --with-ncurses
-
-# compile 'n install
-make
-make install
-
-# compile pinky_curses
-# BSD users should type -D_DEFAULT_SOURCE instead
-gcc -std=c99 -D_POSIX_C_SOURCE=200112L -Wall -Wextra -O2 src/ncurses.c -o pinky_curses -lncurses
-```
-
-Put the following in your shell config as function or alias.
-
-```bash
-pinky() {
- location="${HOME}/.cache/bin"
-
- while true; do
- # scroll a few lines up to see the rest options
- "${location}"/randombar -LTrspkvfmdVt
- sleep 2
- done | "${location}"/pinky_curses
-}
-```
-
-Test it:
-
-```bash
-pinky # Press CTRL + C to stop the program
-```
-
-Put the following in **~/.Xresources**
-
-```bash
-! Xft --------------------------------------------------------------------
-Xft.dpi: 96
-Xft.antialias: true
-Xft.rgba: rgb
-Xft.hinting: true
-Xft.hintstyle: hintslight
-Xft.autohint: false
-Xft.lcdfilter: lcddefault
-
-
-! urxvt conf --------------------------------------------------------------------
-URxvt.buffered : true
-URxvt.cursorBlink : false
-URxvt.cursorUnderline : false
-URxvt.pointerBlank : false
-URxvt.geometry : 80x24
-URxvt.font : xft:DejaVu Sans Mono:bold:pixelsize=11
-URxvt.boldfont : xft:DejaVu Sans Mono:bold:pixelsize=11
-URxvt.letterSpace : -1
-URxvt.termName : rxvt-256color
-URxvt.iso14755 : false
-URxvt.iso14755_52 : false
-URxvt.cursorColor : #ffffff
-URxvt.colorIT : #87af5f
-URxvt.colorBD : #d7d7d7
-URxvt.colorUL : #87afd7
-URxvt.urgentOnBell : false
-URxvt.mapAlert : false
-URxvt.visualBell : false
-URxvt.saveLines : 10000
-URxvt.scrollBar : false
-URxvt.scrollBar_right : false
-URxvt.scrollBar_floating : false
-URxvt.scrollstyle : rxvt
-URxvt.Depth : 32
-URxvt.loginShell : false
-URxvt.insecure : false
-URxvt.pastableTabs : false
-URxvt.utmpInhibit : false
-URxvt.reverseVideo : false
-URxvt.skipBuiltinGlyphs : true
-
-
-! urxvt colours --------------------------------------------------------------------
-*.foreground: #c5c8c6
-*.background: #222222
-*.cursorColor: #ffffff
-
-! black
-*.color0: #222222
-*.color8: #373b41
-
-! red
-*.color1: #ef2929
-*.color9: #ef2929
-
-! green
-*.color2: #8ae234
-*.color10: #8ae234
-
-! yellow
-*.color3: #c2a000
-*.color11: #fce94d
-
-! blue
-*.color4: #5f819d
-*.color12: #81a2be
-
-! magenta
-*.color5: #85678f
-*.color13: #a97fa8
-
-! cyan
-*.color6: #5e8d87
-*.color14: #34e2e2
-
-! white
-*.color7: #ffffff
-*.color15: #ffffff
-
-
-! xterm conf -----------------------------------------------------------
-XTerm.vt100.geometry: 80x24
-XTerm*faceName: DejaVu Sans Book
-XTerm*faceSize: 9
-XTerm*toolBar: off
-
-xterm*termName: xterm-256color
-XTerm*locale: true
-xterm*cursorColor: #FFFFFF
-xterm*toolBar: false
-xterm*scrollBar: false
-xterm*rightScrollBar: false
-xterm*background: #222222
-xterm*foreground: #999999
-xterm*faceName: DejaVu Sans Book:pixelsize=12
-xterm*allowBoldFonts: false
-xterm*geometry: 80x24
-```
-
-Force your non xterm/urxvt terminal emulator to use the newer xterm/urxvt colours. You'll have to kill Xorg (simply logout and log back in), experienced people are using xrdb instead killing Xorg each time they do changes to such files.
-
-pinky\_curses is standalone program not tied to pinky-bar.
-
-```bash
-# ^B - Blue , ^M - Magenta , ^Y - Yellow
-while true; do echo "^BOh ^Mhello ^Ydear";sleep 1;done | ./pinky_curses
-```
-
-## Installation for anything else
-
-pinky-bar is no longer tied to Window Managers only. With the addition of "without colours", the output can be shown in any program, just bear in mind that the more options you've supplied the more system information will be shown.
-
-![](img/pic4.png)
-
-The installation steps:
-
-```bash
-bash bootstrap distro
-./configure --prefix=$HOME/.cache --without-x11 --without-colours
-make
-make install
-```
-
-Will mention that you can add **--with-mpd** too, but scroll a few lines up, re-read **Installation for anything else** and see the tmux snapshot.
-
-By choosing this 3rd installation method it is up to you where, how to start and use the system information that's produced by pinky-bar.
-
----
-
-Replace **distro** with archlinux, debian, gentoo, slackware, rhel, frugalware, angstrom. Here's some short distros list of some popular distros that are based on another one:
-
-- [x] archlinux based distros: parabola, chakra, manjaro
-- [x] debian based distros: ubuntu, linux mint, trisquel, back track, kali linux, peppermint linux, solusos, crunchbang, deepin, elementary os, and the rest \*buntu based distros
-- [x] gentoo based distros: funtoo, sabayon, calculate linux
-- [x] slackware
-- [x] rhel based distros: opensuse (uses rpm), fedora, fuduntu, mandriva, mandrake, viperr, mageia
-- [x] frugalware
-- [x] angstrom
-
-Cannot list the \*BSD flavours as "distros", so they deserve own options:
-
-- [x] freebsd
-- [x] openbsd
-
----
-
-## Linux Mandatory requirements
-
-* gcc/clang
-* glibc
-* autoconf
-* automake
-* m4
-* gawk
-
-## \*BSD Mandatory requirements
-
-* gcc/clang
-* bash
-* autoconf
-* automake
-* autoconf-wrapper
-* automake-wrapper
-* autoconf-archive
-* argp-standalone
-* libtool
-* m4
-* gawk
-
-## Opt-in requirements
-
-The internet related options rely on headers provided iproute2.
-By default the program will try to compile with those headers included.
-If for any reason you would like to compile the program without internet related options, then pass **--without-net** to configure.
-
-* iproute2 # Linux Net headers
-
-The get the NIC vendor and model (linux):
-
-* pciutils
-
-To get the sound volume level:
-
-* alsa-utils
-* alsa-lib
-
-Then pass **--with-alsa** to configure.
-
-\*BSD users can use the baked OSS instead, pass **--without-alsa --with-oss** to configure instead.
-
-To output the data to the terminal using the ncurses library:
-
-* ncurses
-
-To get the vendor and model name of your cdrom/dvdrom/blu-ray:
-
-* libcdio
-* libcddb
-
-In linux **--without-dvd** will still compile the program with dvd support. Except it will be limited only to dvd support, it will try to parse the sr0 vendor and model name detected by the kernel.
-
-Alternative way to obtain sensors values in linux with:
-* lm\_sensors
-
-Jokes aside, but my intention was to make the lm\_sensors api code FreeBSD exclusive, which unfortunately is unsupported in BSD.
-
-To see the currently played song name:
-
-* cmus (only if compiled **--without-mpd**)
-* libmpdclient
-* mpd (with properly configured config)
-
-The FreeBSD users will notice that "mpd" is named "musicpd".
-
-Here's an example of my **/etc/mpd.conf** (linux)
-
-```nginx
-music_directory "/home/frost/music"
-playlist_directory "/home/frost/music"
-db_file "/tmp/mpddb"
-log_file "/tmp/mpdlog"
-state_file "/tmp/mpdstate"
-pid_file "/tmp/mpdpid"
-log_level "default"
-user "mpd"
-
-audio_output {
- type "alsa"
- name "My sound card"
- mixer_type "software"
-}
-
-audio_output {
- type "httpd"
- name "HTTP Stream"
- encoder "vorbis"
- port "8000"
- bitrate "128"
- format "44100:16:1"
-}
-
-bind_to_address "127.0.0.1"
-```
-
-
-FreeBSD conf, you'll have to add the "musicpd" daemon user on your own:
-
-```nginx
-music_directory "/tmp/music"
-playlist_directory "/tmp/music"
-db_file "/tmp/mpddb"
-log_file "/tmp/mpdlog"
-state_file "/tmp/mpdstate"
-pid_file "/tmp/mpdpid"
-log_level "default"
-user "musicpd"
-
-audio_output {
- type "oss"
- name "My sound card"
-}
-
-port "6600"
-bind_to_address "127.0.0.1"
-```
-
-OpenBSD conf, same as the FreeBSD one, just replace audio\_output with:
-
-```nginx
-audio_output {
- type "ao"
- name "My sound card"
- mixer_type "software"
-}
-```
-
-Keep an eye on the **log file size** if you are using raspberry pi (or equivalent device) that streams the music, make sure that it's deleted automatically if it exceeds some pre-defined size.
-
----
-
-## WM specific requirements
-
-If you would like the output to be shown in your Window Manager, those are the following requirements:
-
-for non-dwm WM:
-
-* dzen2
-
-for dwm:
-
-* libx11
-* xorg-server
-
-use **--without-colours** to skip the following step:
-
-* dwm compiled with statuscolor patch applied. The colours in use are specified in your dwm config.h
-
-## Wish list
-
-As top priority:
-
-It would be great if I had \*BSD compatible usb wifi dongle to add wifi options in pinky-bar.
-
----
-
-With the help from the gcc documentation, this wish list option has been solved.
-
-~~Per core/thread CPU frequency detection: Can add it at any time if there is enough demand, but needs some consideration first.~~
-
-~~The kernels cpu frequency governor "performance" will always run at the highest possible clock rate regardless of it's use/idle. The only side effect of this is higher temps when on idle (true if the cpu has multiple cores and or threads).~~
-
-~~The "powersaving" governor will always run at the lowest possible clock rate regardless of it's use/idle. The side effect - slower machine no matter what you do.~~
-
-~~The "ondemand" governor does what it says - ondemand scaling. With it you get the best performance when you need to, powersaving and lower temps when on idle.~~
-
-~~For example I manually turn off the cpu frequency governor in my kernel builds, which sets it to performance.~~
-
-~~The cpu frequency detection is easy, but it poses a roadblock by assuming that the "ondemand" is set and/or is enabled in the user kernel.~~
-
-~~Decision 1: On a multicore/thread cpu, the detection for each core/thread will produce up to 8 digit number, thus 4 core and 4 thread cpu will produce: 1234.5678 1234.5678 1234.5678 1234.5678 1234.5678 1234.5678 1234.5678 1234.5678, without including MHz for each core/thread, which will take a lot of space in the final statusbar output. This way the user will know for how long and which core/thread is under some load.~~
-
-~~Decision 2: On other hand it will be lame on a multi core/thread system to show the overall (not per core/thread) cpu frequency that have been summed up, which will beat the purpose of cpu frequency detection in first place, as the user will not be aware that some core/thread is running at full cpu clock speed as the load will be spread equally when summing the numbers up.~~
-
----
-
-GPU temperature, voltage, fan(s) and used RAM: hard, but not impossible.
-
-It would be nice to have decent gpu temperature, voltage, fan(s) speed and used RAM detection regarding SLI, single and dual gpu cards that doesn't require X, MESA and **/sys/kernel/debug/dri**
-
-Using assembly is strongly no-go.
-
----
-
-[Currently played filename in VLC](https://github.com/videolan/vlc/blob/master/src/libvlc.c): easy to be added.
-
-Unless MPRIS is replaced with sockets, I am not willing to add dbus as dependency to pinky-bar.
-
-```cpp
-// The "MPRIS_BUS_NAME" macro from libvlc
-dbus_message_new_method_call(
- "org.mpris.MediaPlayer2.vlc",
- "/org/mpris/MediaPlayer2",
- "org.mpris.MediaPlayer2.Player",
- "Metadata");
-// results in: 'xesam:url': <'file:///home/frost/music/Summer_Sixteen.mp3'>
-```
-
----
-
-Show the idle time in seconds/minutes: easy to be added via [XScreenSaverQueryInfo](http://linux.die.net/man/3/xscreensaverqueryinfo), but will discriminate the users that have compiled the program **--without-x11**.
-
----
-
-Show the CapsLock/NumLock/ScrollLock indicator status for keyboard without LEDs: easy to be added via [XkbGetIndicatorState](http://linux.die.net/man/3/xkbgetindicatorstate), but will discriminate the users that have compiled the program **--without-x11**.
+++ /dev/null
-#!/usr/bin/env bash
-
-# 07/06/2015, 07/18/2016
-
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-
-declare -a _bases=(
- 'archlinux'
- 'debian'
- 'gentoo'
- 'slackware'
- 'rhel'
- 'frugalware'
- 'angstrom'
- 'freebsd'
- 'openbsd'
-)
-
-_printf_err() {
- printf '%s\n' "try again with: bash ${0} basedistro"
- printf '%s ' "Bases: ${_bases[@]}"
- printf '\n'
-}
-
-_gen_files() {
- progName='pinkybar'
- progVer='1.0.0'
- bsdLibs=''
- osEntered="${1,,}"
- bsdCF='-D_DEFAULT_SOURCE -I/usr/local/include -L/usr/local/lib'
- posixCF='-D_POSIX_C_SOURCE=200112L'
- declare -a srcToAppend
-
- case "${osEntered}" in
- freebsd)
- bsdLibs='-largp -ldevstat'
- amCF="${bsdCF}"
- defTits='m4_define([FREEBZD], [tits])'
- srcToAppend=(
- 'freebsd_functions.c'
- 'include/freebzd.h'
- )
- ;;
- openbsd)
- bsdLibs='-largp -lossaudio'
- amCF="${bsdCF}"
- defTits='m4_define([OPENBZD], [forSure])'
- srcToAppend=(
- 'openbsd_functions.c'
- 'include/openbzd.h'
- )
- ;;
- *)
- amCF="${posixCF}"
- defTits='m4_define([LINUKS], [cryMeAriver])'
- srcToAppend=(
- 'linux_functions.c'
- )
- ;;
- esac
-
-
- # to strip get_packs() at compile time,
- # also instead using more hard-coded macros
- # let the shell enumerate them for us
- declare -a enumDistros=()
- for x in {0..8}
- do
- enumDistros[${x}]="AC_DEFINE_UNQUOTED([${_bases[${x}]^^}],[${x}],[trololo enum generator])"
-
- [[ "${osEntered}" == "${_bases[${x}]}" ]] && {
- distroNum="AC_DEFINE_UNQUOTED([DISTRO],["${x}"],[da monster])"
- }
- done
-
- # configure.ac
- configure_ac=("# This file is processed by autoconf to create a configure script
- AC_INIT(["${progName}"], ["${progVer}"])
- AC_CONFIG_AUX_DIR([temp_dir])
- AC_CONFIG_MACRO_DIR([m4])
- AC_CONFIG_HEADER([src/config.h])
- AM_INIT_AUTOMAKE([1.11 -Wall no-define foreign subdir-objects dist-xz no-dist-gzip std-options])
-
- m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
- "${defTits}"
-
- # With the addition of more runtime compile and
- # link tests, this option is no longer necessary.
- # Any compiler and C library succeeding to pass the
- # tests will be able to compile and run the
- # program flawlessly.
- # If you use OpenBSD uncomment the AC_PROG_CC([])
- # line below. Make sure that you have the latest gcc/llvm
- #AC_PROG_CC([egcc clang llvm-gcc gcc])
-
- AC_PROG_CC_C99
- AC_C_CONST
- AC_HEADER_STDC
- AM_PROG_CC_C_O
-
- # The linker flags tests in m4 dir
- TEST_SOME_FUNCS
- TEST_NET
- TEST_PCI
- TEST_X11
- TEST_ALSA
- TEST_MPD
- TEST_DVD
- TEST_SENSORS
- TEST_TYPEZ
- TEST_CFLAGZ
-
- # Definitions
- "${distroNum}"
- "${enumDistros[@]}"
-
- AC_CONFIG_FILES([
- Makefile
- src/Makefile
- ])
-
- AC_OUTPUT
-
- echo
- echo 'Now type \"make\" and \"make install\" afterwards'
- echo")
-
-
- # Makefile.am
- main_makefile=('
- SUBDIRS = src
- ')
-
-
- # src/Makefile.am
- src_files=(
- 'main.c'
- 'cpu.c'
- 'common.c'
- 'sound.c'
- 'options.c'
- 'net.c'
-
- 'prototypes/cpu.h'
- 'prototypes/common.h'
- 'prototypes/sound.h'
- 'prototypes/net.h'
- 'prototypes/functions.h'
- 'prototypes/options.h'
-
- 'include/headers.h'
- 'include/options_constants.h'
- 'include/functions_constants.h'
- 'include/non_x11_colours.h'
- 'include/x11_colours.h'
- 'include/options_generator.h'
-
- "${srcToAppend[@]}"
- )
-
- # Do not pass more definitions to AM_CFLAGS
- # Think of the line limit
- src_makefile=('AM_CFLAGS = '${amCF}'
-
- bin_PROGRAMS = '${progName}'
-
- '${progName}'_LDADD = $(X_LIBS) $(ALSA_LIBS)
- '${progName}'_LDADD += $(MPD_LIBS) $(PCI_LIBS)
- '${progName}'_LDADD += $(DVD_LIBS) $(SENSORS_LIBS) '${bsdLibs}'
-
- '${progName}'_SOURCES = '${src_files[@]}'
-
- # To satisfy make dist
- EXTRA_DIST = \
- ../bootstrap \
- ../README.md \
- ../.gitignore \
- ../m4 \
- ../xbm_icons
- ')
-
-
- cat <<EOF > configure.ac
-${configure_ac[@]}
-EOF
-
- cat <<EOF > Makefile.am
-${main_makefile[@]}
-EOF
-
- cat <<EOF > src/Makefile.am
-${src_makefile[@]}
-EOF
-
-
- # do not remove nor edit
- autoreconf --install --force
-}
-
-
-[[ -z "${1}" ]] && _printf_err "$@" || {
- [[ " ${_bases[@]} " =~ " ${1,,} " ]] && \
- _gen_files "$@" || _printf_err "$@"
-}
+++ /dev/null
-dnl 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl Internal function to show
-dnl error message when smth is wrong
-AC_DEFUN([ERR],[
- AC_MSG_ERROR($1)
-])
-
-dnl Internal function to show what have to
-dnl be installed in order to compile the program.
-AC_DEFUN([ERR_MUST_INSTALL],[
- ERR([Install $1 in order to compile the program.])
-])
-
-dnl Internal function to show error msg when
-dnl compiling and linking some of tests failed
-AC_DEFUN([LINK_FAILED], [
- ERR([Failed to compile and link the $1 test.])
-])
-
-dnl Internal function to show error msg when
-dnl compiling some of tests failed
-AC_DEFUN([COMPILE_FAILED], [
- ERR([Failed to compile the $1 test.])
-])
-
-dnl Internal function to show error msg when
-dnl some library function is missing
-AC_DEFUN([MISSING_FUNC], [
- ERR([Missing core library functions.])
-])
-
-dnl Internal function to show error msg when
-dnl some header file is missing
-AC_DEFUN([MISSING_HEADER], [
- ERR([Missing core header files.])
-])
+++ /dev/null
-dnl 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl TEST_ALSA() function in configure.ac
-dnl
-dnl Check for the presence of ALSA headers and
-dnl substitute the linker flags -lasound to the
-dnl the variable 'ALSA_LIBS' if they are available.
-AC_DEFUN([TEST_ALSA],[
- ALSA_LIBS=""
-
- AC_ARG_WITH([alsa],
- AS_HELP_STRING([--with-alsa],
- [ALSA linker flag for sound support]),
- [],
- [with_alsa=no]
- )
-
- AC_ARG_WITH([oss],
- AS_HELP_STRING([--with-oss],
- [BSD OSS flag for sound support]),
- [],
- [with_oss=no]
- )
-
- AS_IF([test "x$with_alsa" = "xyes"], [
- AC_CHECK_HEADERS([alsa/asoundlib.h], [
- ALSA_LIBS="-lasound"
- ],[
- ERR_MUST_INSTALL([alsa-utils and alsa-lib])
- ])
-
- m4_foreach([LiB], [
- snd_mixer_open ,
- snd_mixer_attach ,
- snd_mixer_selem_register ,
- snd_mixer_load ,
- snd_mixer_selem_id_malloc ,
- snd_mixer_selem_id_set_name ,
- snd_mixer_find_selem ,
- snd_mixer_selem_get_playback_volume ,
- snd_mixer_selem_get_playback_volume_range ,
- snd_mixer_selem_id_free ,
- snd_mixer_close
- ],[
- AC_CHECK_LIB(asound,LiB,[],[
- MISSING_FUNC()
- ])
- ])
- ])
-
- AC_SUBST(ALSA_LIBS)
-
- AS_IF([test "x$with_alsa" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <alsa/asoundlib.h>
- int main(void) {
- snd_mixer_t *handle = NULL;
- snd_mixer_elem_t *elem = NULL;
- snd_mixer_selem_id_t *s_elem = NULL;
- return 0;
- }
- ]])
- ],[],[
- LINK_FAILED([alsa])
- ]
- )
- ])
-
-
- ifdef([FREEBZD],[
- AS_IF([test "x$with_alsa" = "xno"], [
- AS_IF([test "x$with_oss" = "xyes"], [
- TEST_OZZ([sys/soundcard.h])
- ])
- ])
- ],[])
-
-
- ifdef([OPENBZD],[
- AS_IF([test "x$with_alsa" = "xno"], [
- AS_IF([test "x$with_oss" = "xyes"], [
- TEST_OZZ([soundcard.h])
- ])
- ])
- ],[])
-
-
-])
-
-
-dnl Internal function to check the BSD
-dnl OSS headers and perfom some tests
-AC_DEFUN([TEST_OZZ],[
-
- AC_CHECK_HEADERS([$1], [
- ],[
- ERR([Homie, where is $1 ?])
- ])
-
- NOTIFY([fcntl])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <fcntl.h>
- int main(void) {
- int fd = 0;
- if (-1 == (fd = open("elo", O_RDONLY))) {
- return 0;
- }
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([fcntl])
- ]
- )
-
-])
+++ /dev/null
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
-#
-# DESCRIPTION
-#
-# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
-# added in between.
-#
-# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
-# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
-# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
-# FLAG.
-#
-# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
-# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.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/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
-
-#serial 6
-
-AC_DEFUN([AX_APPEND_FLAG],
-[dnl
-AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
-AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
-AS_VAR_SET_IF(FLAGS,[
- AS_CASE([" AS_VAR_GET(FLAGS) "],
- [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
- [
- AS_VAR_APPEND(FLAGS,[" $1"])
- AC_RUN_LOG([: FLAGS="$FLAGS"])
- ])
- ],
- [
- AS_VAR_SET(FLAGS,[$1])
- AC_RUN_LOG([: FLAGS="$FLAGS"])
- ])
-AS_VAR_POPDEF([FLAGS])dnl
-])dnl AX_APPEND_FLAG
+++ /dev/null
-dnl 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl Internal function to perform
-dnl explicit compiler CFLAGS support test
-AC_DEFUN([CHECK_CFLAGZ],[
- m4_foreach([fLaG], [$1], [
-
- AX_APPEND_FLAG([fLaG], [CFLAGS])
-
- AC_MSG_CHECKING([whether fLaG will compile flawlessly])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[ int main(void) { return 0; } ]])
- ],[cflagz_ok=yes],[cflagz_ok=no])
-
- AC_MSG_RESULT([$cflagz_ok])
-
- AS_IF([test "x$cflagz_ok" = "xno"], [
- ERR([Failed to compile a simple test with the above fLaG CFLAG.])
- ]
- )
-
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[ int main(void) { return 0; } ]])
- ],[],[
- ERR([Failed to compile and link a simple test with the above fLaG CFLAG.])
- ]
- )
-
- ])dnl
-
-])
-
-dnl Internal function to check
-dnl the compiler for assembly support
-AC_DEFUN([TEST_ASSEMBLY],[
-
- AC_MSG_CHECKING([for assembly support])
-
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
- #include <stdint.h>]],[[
- uintmax_t x;
- __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (x));
- ]])
- ],[supportz_assembly=yes],[supportz_assembly=no])
-
- AC_MSG_RESULT([$supportz_assembly])
-
- AS_IF([test "x$supportz_assembly" = "xno"], [
- ERR([Your compiler does not support assembly.])
- ]
- )
-
-])
-
-dnl TEST_CFLAGZ() function in configure.ac
-dnl
-dnl Check for the presence and whether
-dnl the given FLAG will work flawlessly
-dnl with the currently used compiler.
-dnl Will substitute each successful flag
-dnl and bail out with pre-defined error msg
-dnl when some FLAG is unsupported.
-AC_DEFUN([TEST_CFLAGZ],[
-
- dnl Only useful when developing
- dnl pinky-bar
- dnl -Wdeclaration-after-statement,
- dnl -Wno-unused-function,
-
- dnl Shame on you c++lang, err clang
- dnl Keeping this flag for historical
- dnl reasons just to remind myself and
- dnl anyone reading this file about the
- dnl clangs inabillity to distinguish
- dnl C from C++
- dnl https://llvm.org/bugs/show_bug.cgi?id=21689
- dnl -Wno-missing-field-initializers
-
- dnl The twisted gcc vision
- dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
- dnl They say its "glibc" fault
- dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
- dnl -Wno-unused-result,
-
- dnl For very first time I stumble upon GCC -O2 bug.
- dnl It hangs on pci_init and sensors_init with -O2
- dnl net.m4 will append -O2 or -O0
- dnl according whether --with-pci and --with-sensors
- dnl are used or not. Another "newer" GCC release
- dnl that I just installed hangs on sensors_init.
- dnl One more snafu GCC, and I'll drop -02 in linux
-
- AC_MSG_NOTICE([checking all CFLAGS])
- CHECK_CFLAGZ([
- -pipe,
- -std=c99,
- -Wextra,
- -Wall,
- -pedantic,
- -Wundef,
- -Wshadow,
- -W,
- -Wwrite-strings,
- -Wcast-align,
- -Wstrict-overflow=5,
- -Wconversion,
- -Wpointer-arith,
- -Wstrict-prototypes,
- -Wformat=0,
- -Wsign-compare,
- -Wendif-labels,
- -Wredundant-decls,
- -Wmissing-prototypes,
- -Wno-unused-variable
- ])
-
- TEST_ASSEMBLY()
-
-])
+++ /dev/null
-dnl 08/23/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl TEST_DVD() function in configure.ac
-dnl
-dnl Substitute the linker flags -lcdio to the
-dnl the variable 'DVD_LIBS' if the user enabled
-dnl the --with-dvd switch
-AC_DEFUN([TEST_DVD],[
- DVD_LIBS=""
-
- AC_ARG_WITH([dvd],
- AS_HELP_STRING([--with-dvd],
- [dvd linker flag to show the vendor and model name of your cd/dvdrom]),
- [],
- [with_dvd=no]
- )
-
- AS_IF([test "x$with_dvd" = "xyes"], [
- AC_CHECK_HEADERS([ \
- cdio/cdio.h \
- cdio/mmc.h \
- ], [
- DVD_LIBS="-lcdio"
- ],[
- ERR_MUST_INSTALL([libcdio])
- ])
-
- m4_foreach([LiB], [
- cdio_open ,
- mmc_get_hwinfo ,
- cdio_destroy
- ],[
- AC_CHECK_LIB(cdio,LiB,[],[
- MISSING_FUNC()
- ])
- ])
- ])
-
- AC_SUBST(DVD_LIBS)
-
- AS_IF([test "x$with_dvd" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <stdlib.h>
- #include <cdio/cdio.h>
- #include <cdio/mmc.h>
- int main(void) {
- CdIo_t *p_cdio = cdio_open(NULL, DRIVER_DEVICE);
- cdio_hwinfo_t hwinfo;
- if (NULL == p_cdio) {
- return 0;
- }
- if (mmc_get_hwinfo(p_cdio, &hwinfo)) {
- printf("%s %s\n", hwinfo.psz_vendor, hwinfo.psz_model);
- }
- if (NULL != p_cdio) {
- cdio_destroy(p_cdio);
- }
- return 0;
- }
- ]])
- ],[],[
- LINK_FAILED([cdio])
- ]
- )
- ])
-
-])
+++ /dev/null
-dnl 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl TEST_MPD() function in configure.ac
-dnl
-dnl Substitute the linker flags -lmpdclient to the
-dnl the variable 'MPD_LIBS' if the user enabled
-dnl the --with-mpd switch
-AC_DEFUN([TEST_MPD],[
- MPD_LIBS=""
-
- AC_ARG_WITH([mpd],
- AS_HELP_STRING([--with-mpd],
- [mpd linker flag to show the currently played song]),
- [],
- [with_mpd=no]
- )
-
- AS_IF([test "x$with_mpd" = "xyes"], [
- AC_CHECK_HEADERS([mpd/client.h], [
- MPD_LIBS="-lmpdclient"
- ],[
- ERR_MUST_INSTALL([libmpdclient])
- ])
-
- m4_foreach([LiB], [
- mpd_connection_new ,
- mpd_send_command ,
- mpd_recv_song ,
- mpd_connection_get_error ,
- mpd_connection_free ,
- mpd_song_free ,
- mpd_song_get_uri
- ],[
- AC_CHECK_LIB(mpdclient,LiB,[],[
- MISSING_FUNC()
- ])
- ])
- ])
-
- AC_SUBST(MPD_LIBS)
-
- AS_IF([test "x$with_mpd" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <mpd/client.h>
- int main(void) {
- struct mpd_connection *conn = NULL;
- struct mpd_song *song;
- if (NULL == (conn = mpd_connection_new(NULL, 0, 0))) {
- return 0;
- }
- mpd_connection_free(conn);
- return 0;
- }
- ]])
- ],[],[
- LINK_FAILED([mpd])
- ]
- )
- ])
-
-])
+++ /dev/null
-dnl 08/10/2015
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl TEST_NET() function in configure.ac
-dnl
-dnl Allow the user to compile the program
-dnl without net related functions, thus
-dnl decreasing the required dependencies.
-dnl
-dnl Did not included tests for some of the Net
-dnl headers as they fail to compile just by including
-dnl them in gcc, but pass the tests in clang. Is there
-dnl are any _POSIX_SOURCE m4 alternative to compile a
-dnl test case on the fly ?
-dnl
-dnl --with-net will check for the presence of iproute2 headers
-dnl used in the net functions and substitute appropriate macro
-dnl so the program to be compiled with/out net functions support.
-AC_DEFUN([TEST_NET],[
- WITH_NET=1
-
- AC_ARG_WITH([net],
- AS_HELP_STRING([--with-net],
- [Net funcs]),
- [],
- [with_net=yes]
- )
-
- AS_IF([test "x$with_net" = "xno"], [
- WITH_NET=0
- ])
-
- AS_IF([test "x$with_net" = "xyes"], [
-
- AC_CHECK_HEADERS([ \
- ifaddrs.h \
- arpa/inet.h \
- sys/socket.h \
- sys/ioctl.h \
- netdb.h \
- ],[],[
- MISSING_HEADER()
- ])
-
- ifdef([FREEBZD], [
- AC_CHECK_HEADERS([ \
- arpa/nameser.h \
- netinet/in.h \
- net/if.h \
- net/if_dl.h \
- ],[],[
- MISSING_HEADER()
- ])
-
- ],[
-
- ifdef([LINUKS], [
- AC_CHECK_HEADERS([ \
- linux/if_link.h \
- netpacket/packet.h \
- linux/sockios.h \
- linux/ethtool.h \
- ],[],[
- MISSING_HEADER()
- ])
- ],[
- ])
-
- ])
-
- AC_CHECK_FUNCS([ \
- getifaddrs \
- freeifaddrs \
- getaddrinfo \
- freeaddrinfo \
- socket \
- ioctl \
- inet_ntop \
- ],[],[
- MISSING_FUNC()
- ])
-
- NOTIFY([addrinfo])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <string.h>
- #include <netdb.h>
- #include <sys/socket.h>
- int main(void) {
- struct addrinfo *rp = NULL, *result = NULL;
- struct addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_flags = 0;
- hints.ai_protocol = 0;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([addrinfo])
- ]
- )
-
- NOTIFY([getifaddrs-lite])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <ifaddrs.h>
- int main(void) {
- struct ifaddrs *ifaddr;
- if (-1 == getifaddrs(&ifaddr)) {
- return 0;
- }
- freeifaddrs(ifaddr);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([getifaddrs-lite])
- ]
- )
-
- ifdef([FREEBZD],[
- NOTIFY([getifaddrs-heavy])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <arpa/inet.h>
- #include <arpa/nameser.h>
- #include <ifaddrs.h>
- #include <net/if.h>
- #include <net/if_dl.h>
- int main(void) {
- struct ifaddrs *ifaddr = NULL, *ifa = NULL;
- struct if_data *stats = NULL;
- struct sockaddr_dl *mac = NULL;
- if (-1 == getifaddrs(&ifaddr)) {
- return 0;
- }
- freeifaddrs(ifaddr);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([getifaddrs-heavy])
- ]
- )
- ],[])
-
-
- ])
-
- AC_DEFINE_UNQUOTED([WITH_NET],[$WITH_NET],[Net funcs])
-
-])
-
-dnl TEST_PCI() function in configure.ac
-dnl
-dnl Allow the user to compile the program
-dnl without pci related functions, thus
-dnl decreasing the required dependencies.
-dnl
-dnl --with-pci will check for the presence of pci headers and
-dnl substitute the linker flags -lpci to the variable PCI_LIBS
-dnl as well will mitigate the GCC -O2 bug.
-AC_DEFUN([TEST_PCI],[
- WITH_PCI=1
- PCI_LIBS=""
-
- AC_ARG_WITH([pci],
- AS_HELP_STRING([--with-pci],
- [PCI funcs]),
- [],
- [with_pci=yes]
- )
-
- ifdef([LINUKS],[],[
- WITH_PCI=0
- CHECK_CFLAGZ([-O2])
- ])
-
- ifdef([LINUKS],[
- AS_IF([test "x$with_pci" = "xno"], [
- WITH_PCI=0
- ifdef([GOT_SENSR],[
- CHECK_CFLAGZ([-O0])
- ],[
- CHECK_CFLAGZ([-O2])
- ])
- m4_define([NO_PCI],[thenFryAGP])
- ])
-
- AS_IF([test "x$with_pci" = "xyes"], [
-
- dnl For very first time I stumble upon GCC -O2 bug.
- dnl It hangs on pci_init with -O2
- CHECK_CFLAGZ([-O0])
-
- AC_CHECK_HEADERS([pci/pci.h], [
- PCI_LIBS="-lpci"
- ],[
- ERR_MUST_INSTALL([pciutils])
- ])
-
- m4_foreach([LiB], [
- pci_alloc ,
- pci_init ,
- pci_scan_bus ,
- pci_fill_info ,
- pci_lookup_name ,
- pci_cleanup
- ],[
- AC_CHECK_LIB(pci,LiB,[],[
- MISSING_FUNC()
- ])
- ])
-
- ])
-
- AC_SUBST(PCI_LIBS)
-
- AS_IF([test "x$with_pci" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <pci/pci.h>
- int main(void) {
- struct pci_access *pacc= NULL;
- pacc = pci_alloc();
- pci_init(pacc);
- pci_scan_bus(pacc);
- if (NULL != pacc) {
- pci_cleanup(pacc);
- }
- return 0;
- }
- ]])
- ],[],[
- LINK_FAILED([pci])
- ]
- )
- ])
-
- ],[
- ])
-
- AC_DEFINE_UNQUOTED([WITH_PCI],[$WITH_PCI],[PCI funcs])
-
-])
+++ /dev/null
-dnl 08/23/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl TEST_SENSORS() function in configure.ac
-dnl
-dnl Substitute the linker flags -lsensors to the
-dnl the variable 'SENSORS_LIBS' if the user enabled
-dnl the --with-sensors switch
-AC_DEFUN([TEST_SENSORS],[
- SENSORS_LIBS=""
-
- AC_ARG_WITH([sensors],
- AS_HELP_STRING([--with-sensors],
- [lm sensors linker flag to obtain voltage, mobo temp and fans]),
- [],
- [with_sensors=no]
- )
-
- ifdef([LINUKS],[
- AS_IF([test "x$with_sensors" = "xyes"], [
- AC_CHECK_HEADERS([sensors/sensors.h], [
- SENSORS_LIBS="-lsensors"
- ],[
- ERR_MUST_INSTALL([lm_sensors])
- ])
-
- m4_foreach([LiB], [
- sensors_init,
- sensors_get_value,
- sensors_get_label,
- sensors_get_detected_chips,
- sensors_get_features,
- sensors_get_all_subfeatures,
- sensors_cleanup
- ],[
- AC_CHECK_LIB(sensors,LiB,[],[
- MISSING_FUNC()
- ])
- ])
- ])
- ],[
- ])
-
- ifdef([FREEBZD],[
- AC_ARG_VAR(mobo_sensor, [mobo sensors module name to use in sysctl calls])
- if [[ ! -z "${mobo_sensor}" ]]
- then
- MOBO_MODL=\""${mobo_sensor}"\"
- AC_DEFINE_UNQUOTED([MOBO_MODL],[$MOBO_MODL],[mobo sensors module])
- fi
-
- AC_ARG_VAR(cpu_sensor, [cpu sensors module name to use in sysctl calls])
- if [[ ! -z "${cpu_sensor}" ]]
- then
- CPU_MODL=\""${cpu_sensor}"\"
- AC_DEFINE_UNQUOTED([CPU_MODL],[$CPU_MODL],[cpu sensors module])
- fi
-
- GOT_APM=0
- AC_ARG_WITH([apm],
- AS_HELP_STRING([--with-apm],
- [APM power and resource management for laptops]),
- [],
- [with_apm=no]
- )
- AS_IF([test "x$with_apm" = "xyes"], [
- AC_CHECK_HEADERS([machine/apm_bios.h], [
- GOT_APM=1
- ],[
- MISSING_HEADER()
- ])
- ])
- AC_DEFINE_UNQUOTED([GOT_APM],[$GOT_APM],[APM power and resource management for laptops])
-
- ],[
- ])
-
- AC_SUBST(SENSORS_LIBS)
-
- ifdef([LINUKS],[
- AS_IF([test "x$with_sensors" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <sensors/sensors.h>
- int main(void) {
- int nr = 0, nr2 = 0, nr3 = 0;
- const sensors_chip_name *chip;
- const sensors_feature *features;
- const sensors_subfeature *subfeatures;
- double value = 0.0;
- char *label = NULL;
-
- if (0 != (sensors_init(NULL))) {
- return 0;
- }
-
- while (NULL != (chip = sensors_get_detected_chips(NULL, &nr))) {
- nr2 = 0;
- while (NULL != (features = sensors_get_features(chip, &nr2))) {
- nr3 = 0;
- while (NULL != (subfeatures = sensors_get_all_subfeatures(chip, features, &nr3))) {
- switch(subfeatures->type) {
-
- case SENSORS_SUBFEATURE_IN_INPUT:
- case SENSORS_SUBFEATURE_TEMP_INPUT:
- case SENSORS_SUBFEATURE_FAN_INPUT:
- {
- if (0 != (sensors_get_value(chip, subfeatures->number, &value))) {
- break;
- }
- if (NULL == (label = sensors_get_label(chip, features))) {
- break;
- }
- printf("%f\n", (float)value);
- if (NULL != label) {
- free(label);
- }
- }
- break;
- default:
- continue;
- }
- }
- }
- }
- sensors_cleanup();
-
- return 0;
- }
- ]])
- ],[],[
- ERR([Either you miss lm_sensors or your lm_sensors API version is unsupported by pinky-bar.])
- ]
- )
- ])
-
- ],[
- ])
-
-
- ifdef([OPENBZD], [
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/sensors.h>
- int main(void) {
- struct sensordev dev;
- struct sensor sens;
- SENSOR_VOLTS_DC;
- SENSOR_TEMP;
- SENSOR_FANRPM;
- SENSOR_FINVALID;
- SENSOR_FUNKNOWN;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([sensors])
- ]
- )
- ],[
- ])
-
- AS_IF([test "x$with_sensors" = "xyes"], [
- ifdef([NO_PCI],[
- CHECK_CFLAGZ([-O0])
- ],[])
- m4_define([GOT_SENSR],[meltCPU])
- ])
-
-])
+++ /dev/null
-dnl 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl Internal function to let the user know
-dnl when some of the compile tests is about to begin
-AC_DEFUN([NOTIFY],[
- AC_MSG_NOTICE([performing $1 compile test.])
-])
-
-
-dnl TEST_SOME_FUNCS() function in configure.ac
-dnl
-dnl The tests are simple enough, just to
-dnl catch misbehaving compiler and/or
-dnl installed C libraries.
-AC_DEFUN([TEST_SOME_FUNCS],[
-
- NOTIFY([strftime])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <time.h>
- int main(void) {
- char test[200];
- time_t t = time(NULL);
- strftime(test, 190, "%I:%M %p", localtime(&t));
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([strftime])
- ]
- )
-
-
- NOTIFY([statvfs])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdlib.h>
- #include <sys/statvfs.h>
- int main(void) {
- struct statvfs ssd;
- statvfs(getenv("HOME"), &ssd);
- ssd.f_blocks;
- ssd.f_bsize;
- ssd.f_bavail;
- ssd.f_bfree;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([statvfs storage])
- ]
- )
-
-
- NOTIFY([uname])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <sys/utsname.h>
- int main(void) {
- struct utsname KerneL;
- uname(&KerneL);
- KerneL.sysname;
- KerneL.nodename;
- KerneL.release;
- KerneL.version;
- KerneL.machine;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([uname Kernel])
- ]
- )
-
-
- ifdef([LINUKS],[
- NOTIFY([sysinfo])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <sys/sysinfo.h>
- int main(void) {
- struct sysinfo inf;
- sysinfo(&inf);
- inf.totalram;
- inf.freeram;
- inf.sharedram;
- inf.bufferram;
- inf.loads[0];
- inf.loads[1];
- inf.loads[2];
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([sysinfo RAM and average load])
- ]
- )
-
- ],[])
-
-
- NOTIFY([openNreadFile])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- int main(void) {
- FILE *test = fopen("/proc/stat", "r");
- if (NULL == test) {
- return 0;
- }
- fclose(test);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([openNreadFile])
- ]
- )
-
-
- NOTIFY([memset])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <string.h>
- #include <stdint.h>
- int main(void) {
- uintmax_t test[5];
- memset(test, 0, sizeof(test));
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([memset])
- ]
- )
-
-
- ifdef([LINUKS],[
- NOTIFY([glob])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <glob.h>
- int main(void) {
- glob_t gl;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([glob])
- ]
- )
-
- ],[])
-
-
- NOTIFY([sysconf])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <time.h>
- #include <unistd.h>
- int main(void) {
- if (-1 == (sysconf(_SC_CLK_TCK))) {
- return 0;
- }
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([sysconf])
- ]
- )
-
-
- NOTIFY([snprintf])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- int main(void) {
- char test[10];
- snprintf(test, 8, "%s", "hi");
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([snprintf])
- ]
- )
-
-
- NOTIFY([getopt])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <getopt.h>
- #define NULL ((void *)0)
- int main(void) {
- const struct option options[] = {
- { "mpd", no_argument, NULL, 'M' },
- { "statio", required_argument, NULL, 'S' },
- { NULL, 0, NULL, 0 }
- };
-
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([getopt])
- ]
- )
-
-
- NOTIFY([timespec])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <time.h>
- int main(void) {
- struct timespec tc = {0};
- tc.tv_nsec = 85000L;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([timespec])
- ]
- )
-
-
- NOTIFY([popen])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- int main(void) {
- char hi[30];
- FILE *test = popen("echo elo", "r");
- fscanf(test, "%s", hi);
- pclose(test);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([popen])
- ]
- )
-
-
- NOTIFY([clock_gettime])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <time.h>
- int main(void) {
- struct timespec tc1 = {0}, tc2 = {0};
- clock_gettime(CLOCK_MONOTONIC, &tc1);
-
- #if defined(__linux__)
- clock_gettime(CLOCK_BOOTTIME, &tc2);
- #endif
-
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([clock_gettime])
- ]
- )
-
-
- ifdef([FREEBZD],[
- NOTIFY([getloadavg])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdlib.h>
- int main(void) {
- double up[3];
- getloadavg(up, 3);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([getloadavg])
- ]
- )
-
-
- NOTIFY([sysctl])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/sysctl.h>
- #define SYSCTLVAL(x, y, z) \
- if (0 != sysctlbyname(x, y, z, NULL, 0)) { \
- return 0; \
- }
- int main(void) {
- u_int dummy = 0;
- size_t len = sizeof(dummy);
- SYSCTLVAL("vm.stats.vm.v_page_size", &dummy, &len);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([sysctl])
- ]
- )
-
-
- NOTIFY([malloc])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <stdlib.h>
- int main(void) {
- char *a = (char *)malloc(10);
- if (NULL == a) {
- return 0;
- }
- free(a);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([malloc])
- ]
- )
-
- m4_foreach([LiB], [
- devstat_checkversion ,
- devstat_getdevs ,
- devstat_selectdevs
- ],[
- AC_CHECK_LIB(devstat,LiB,[],[
- MISSING_FUNC()
- ])
- ])
-
- NOTIFY([devstat])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <stdlib.h>
- #include <devstat.h>
- int main(void) {
- struct statinfo stats;
- struct device_selection *dev_select = NULL;
- struct devstat *d = NULL;
- devstat_checkversion(NULL);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([devstat])
- ]
- )
-
- m4_foreach([LiB], [
- argp_parse ,
- argp_usage
- ],[
- AC_CHECK_LIB(argp,LiB,[],[
- MISSING_FUNC()
- ])
- ])
-
-
- NOTIFY([xswdev-swap])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <inttypes.h>
- #include <sys/types.h>
- #include <sys/param.h>
- #include <sys/stat.h>
- #include <sys/sysctl.h>
- #include <vm/vm_param.h>
- int main(void) {
- struct xswdev xsw;
- u_int pagesize = 4096, dummy = 0;
- uintmax_t total = 0, used = 0, pz = 0;
- int mib[20];
- memset(mib, 0, sizeof(mib));
- size_t mibi = sizeof(mib) / sizeof(mib[0]);
- size_t len = sizeof(dummy), sisi = sizeof(struct xswdev);
-
- pz = (uintmax_t)pagesize;
- if (0 != (sysctlnametomib("vm.swap_info", mib, &mibi))) {
- return 0;
- }
- if (0 != (sysctl(mib, (u_int)(mibi + 1), &xsw, &sisi, NULL, 0))) {
- return 0;
- }
- if (xsw.xsw_version != XSWDEV_VERSION) {
- return 0;
- }
- used = (uintmax_t)xsw.xsw_used;
- total = (uintmax_t)xsw.xsw_nblks;
-
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([xswdev-swap])
- ]
- )
-
- ],[])
-
-
- ifdef([OPENBZD],[
- NOTIFY([swapctl])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <sys/swap.h>
- int main(void) {
- struct swapent *dev = NULL;
- swapctl(SWAP_NSWAP, 0, 0);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([swapctl])
- ]
- )
-
- NOTIFY([apm battery])
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdio.h>
- #include <string.h>
- #include <stdint.h>
- #include <fcntl.h>
- #include <sys/ioctl.h>
- #include <machine/apmvar.h>
- int main(void) {
- struct apm_power_info bstate;
- int fd = 0;
- uintmax_t dummy = 0;
- memset(&bstate, 0, sizeof(struct apm_power_info));
- if (0 != (fd = open("/dev/apm", O_RDONLY))) {
- return 0;
- }
- if (0 != (ioctl(fd, APM_IOC_GETPOWER, &bstate))) {
- close(fd);
- return 0;
- }
- close(fd);
- if (APM_BATT_UNKNOWN == bstate.battery_state ||
- APM_BATTERY_ABSENT == bstate.battery_state) {
- return 0;
- }
- dummy = (uintmax_t)bstate.battery_life;
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([apm battery])
- ]
- )
-
- ],[])
-
-
-
-])
+++ /dev/null
-dnl 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl Internal function to perform
-dnl explicit data check type
-AC_DEFUN([CHECK_TYPEZ],[
- AC_CHECK_TYPES([$1],[],[
- AC_MSG_WARN([Some C data type failed, checking which one.])
- m4_foreach([tYpe], [$1],[
- AC_CHECK_SIZEOF(tYpe)
- ])dnl
- ERR([Your compiler does not understand C data types.])
- ])
-])
-
-
-dnl TEST_TYPEZ() function in configure.ac
-dnl
-dnl Check for the presence of all used
-dnl library functions, their header files
-dnl and some int types. 64bit is not
-dnl mandatory since uintmax makes it
-dnl easy for us.
-AC_DEFUN([TEST_TYPEZ],[
-
- CHECK_TYPEZ([
- size_t,
- time_t,
- float,
- double,
- signed char,
- unsigned char,
- signed short int,
- int8_t,
- signed int,
- int16_t,
- signed long int,
- int32_t,
- intmax_t,
- unsigned short int,
- uint8_t,
- unsigned int,
- uint16_t,
- unsigned long int,
- uint32_t,
- uintmax_t,
- int_least8_t,
- int_least16_t,
- int_least32_t,
- uint_least8_t,
- uint_least16_t,
- uint_least32_t,
- int_fast8_t,
- int_fast16_t,
- int_fast32_t,
- uint_fast8_t,
- uint_fast16_t,
- uint_fast32_t
- ])
-
- AC_CHECK_HEADERS([ \
- time.h \
- stdio.h \
- stdbool.h \
- string.h \
- inttypes.h \
- sys/statvfs.h \
- sys/utsname.h \
- unistd.h \
- getopt.h \
- sys/socket.h \
- ],[],[
- MISSING_HEADER()
- ])
-
- ifdef([FREEBZD], [
- AC_CHECK_HEADERS([ \
- sys/types.h \
- sys/sysctl.h \
- sys/param.h \
- sys/stat.h \
- vm/vm_param.h \
- ],[],[
- MISSING_HEADER()
- ])
-
- ], [
- ifdef([LINUKS],[
- AC_CHECK_HEADERS([ \
- argp.h \
- sys/sysinfo.h \
- glob.h \
- ],[],[
- MISSING_HEADER()
- ])
- ],[
- ])
-
- ])
-
- AC_CHECK_FUNCS([ \
- memset \
- printf \
- snprintf \
- nanosleep \
- sysconf \
- strcmp \
- fscanf \
- fclose \
- fopen \
- statvfs \
- getenv \
- popen \
- uname \
- strftime \
- exit \
- getopt \
- getopt_long \
-
- ],[],[
- MISSING_FUNC()
- ])
-
- ifdef([FREEBZD], [
- AC_CHECK_FUNCS([ \
- sysctl \
- sysctlbyname \
- sysctlnametomib \
- getloadavg \
- malloc \
- free \
- ],[],[
- MISSING_FUNC()
- ])
-
- ], [
-
- ifdef([LINUKS],[
- AC_CHECK_FUNCS([ \
- sysinfo \
- glob \
- globfree \
- argp_parse \
- argp_usage \
- ],[],[
- MISSING_FUNC()
- ])
- ],[
- ])
-
- ])
-
-])
+++ /dev/null
-dnl Copyright 07/06/2015, 08/03/2016
-
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-dnl MA 02110-1301, USA.
-
-
-dnl TEST_X11() function in configure.ac
-dnl
-dnl Check for the presence of X11 headers and
-dnl substitute the linker flags -lX11 to the
-dnl the variable 'X_LIBS' if they are available.
-AC_DEFUN([TEST_X11],[
- X_LIBS=""
-
- AC_ARG_WITH([x11],
- AS_HELP_STRING([--with-x11],
- [X11 linker flag for dwm support]),
- [],
- [with_x11=yes]
- )
-
- AS_IF([test "x$with_x11" = "xyes"], [
- AC_CHECK_HEADERS([X11/Xlib.h], [
- X_LIBS="-lX11"
- ],[
- ERR_MUST_INSTALL([xorg and libx11])
- ])
-
- m4_foreach([LiB], [
- XOpenDisplay,
- XStoreName,
- XSync,
- XCloseDisplay
- ],[
- AC_CHECK_LIB(X11,LiB,[],[
- MISSING_FUNC()
- ])
- ])dnl
- ])
-
- WITH_COLOURS=0
- AC_ARG_WITH([colours],
- AS_HELP_STRING([--with-colours],
- [Colorize the output]),
- [],
- [with_colours=yes]
- )
- AS_IF([test "x$with_colours" = "xyes"], [
- WITH_COLOURS=1
- ])
- AC_DEFINE_UNQUOTED([WITH_COLOURS],[$WITH_COLOURS],[Colorize the output])
-
- dnl xbm icons for non-dwm window manager
- AC_ARG_VAR(icons, [path to xbm icons for non-dwm WM])
- if [[ ! -z "${icons}" ]]
- then
- dnl Da stupid shell expansion only works on "UNQUOTED"
- ICONZ=\""${icons}"\"
- AC_DEFINE_UNQUOTED([ICONS_DIR],[$ICONZ],[xbm icons for non-dwm WM])
- fi
-
- AC_SUBST(X_LIBS)
-
- AS_IF([test "x$with_x11" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <X11/Xlib.h>
- int main(void) {
- Display *display;
- Window window;
- XEvent evt;
- return 0;
- }
- ]])
- ],[],[
- LINK_FAILED([X11])
- ]
- )
- ])
-
- AS_IF([test "x$with_x11" = "xno"], [
- TEST_NCURSES()
- ])
-
-])
-
-
-dnl Test for the presence of the ncurses library
-dnl and substitute macro to determine whether the
-dnl program to be compiled with/out ncurses colours
-AC_DEFUN([TEST_NCURSES], [
- WITH_NCURSES=0
-
- AC_ARG_WITH([ncurses],
- AS_HELP_STRING([--with-ncurses],
- [Output the data to your terminal using the ncurses library.]),
- [],
- [with_ncurses=no]
- )
-
- AS_IF([test "x$with_ncurses" = "xyes"], [
- AC_CHECK_HEADERS([ncurses.h], [
- WITH_NCURSES=1
- ],[
- ERR_MUST_INSTALL([ncurses])
- ])
-
- m4_foreach([LiB], [
- initscr ,
- noecho ,
- cbreak ,
- halfdelay ,
- nonl ,
- intrflush ,
- curs_set ,
- start_color ,
- init_pair ,
- refresh ,
- clear ,
- endwin ,
- has_colors ,
- pair_content ,
- wattrset ,
- waddch
- ],[
- AC_CHECK_LIB(ncurses,LiB,[],[
- MISSING_FUNC()
- ])
- ])
- ])
-
- AS_IF([test "x$with_ncurses" = "xyes"], [
- AC_LINK_IFELSE([
- AC_LANG_SOURCE([[
- #include <ncurses.h>
- int main(void) {
- initscr();
- printw("elo");
- refresh();
- endwin();
- return 0;
- }
- ]])
- ],[],[
- LINK_FAILED([ncurses])
- ]
- )
-
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- #include <stdlib.h>
- #include <unistd.h>
- #include <signal.h>
- void sighandler(int num);
- void sighandler(int num) {
- exit(1);
- }
- int main(void) {
- signal(SIGINT, sighandler);
- return 0;
- }
- ]])
- ],[],[
- COMPILE_FAILED([signal])
- ]
- )
-
- ])
-
- AC_DEFINE_UNQUOTED([WITH_NCURSES],[$WITH_NCURSES],[Where to output the data])
-
-])
+++ /dev/null
-# Created by: Aaron Caffrey
-# $FreeBSD$
-
-PORTNAME= pinky-bar
-PORTVERSION= 1.0.0
-CATEGORIES= sysutils
-
-MAINTAINER= wifiextender@null.horse
-COMMENT= Gather some system information
-
-USE_GITHUB= yes
-GH_ACCOUNT= wifiextender
-GH_PROJECT= pinky-bar
-GH_TAGNAME= 4252f74
-
-GNU_CONFIGURE= yes
-USE_XORG+= x11
-LDFLAGS+= -L${LOCALBASE}/lib
-CFLAGS+= -I${LOCALBASE}/include
-CONFIGURE_ARGS= --without-pci --without-sensors
-CONFIGURE_ARGS+= --prefix=/usr/local icons=/usr/local/share/icons/xbm_icons
-LIB_DEPENDS= libargp.so:devel/argp-standalone
-BUILD_DEPENDS= git:devel/git tar:archivers/gtar gzip:archivers/gzip
-BUILD_DEPENDS+= gm4:devel/m4 libtool:devel/libtool autoconf:devel/autoconf
-BUILD_DEPENDS+= automake:devel/automake bash:shells/bash
-
-OPTIONS_DEFINE= X11 ALSA OSS NET DVD MPD COLOURS NCURSES
-OPTIONS_DEFAULT= OSS
-X11_CONFIGURE_WITH= x11
-ALSA_CONFIGURE_WITH= alsa
-OSS_CONFIGURE_WITH= oss
-NET_CONFIGURE_WITH= net
-DVD_CONFIGURE_WITH= dvd
-MPD_CONFIGURE_WITH= mpd
-NCURSES_CONFIGURE_WITH= ncurses
-COLOURS_CONFIGURE_WITH= colours
-
-X11_DESC= Enable it if you are using dwm
-ALSA_DESC= To get the sound volume level
-OSS_DESC= The default way to get the sound volume level
-NET_DESC= Enable the internet related options
-DVD_DESC= To get the cdrom/dvdrom vendor and model names
-MPD_DESC= To see the currently played song name
-NCURSES_DESC= Output the data to the terminal using ncurses
-COLOURS_DESC= Colorize the output data
-
-X11_LIB_DEPENDS= libX11.so:x11/xorg
-ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib
-DVD_LIB_DEPENDS= libcdio.so:sysutils/libcdio libcddb.so:audio/libcddb
-NCURSES_LIB_DEPENDS= libncurses.so:devel/ncurses
-MPD_LIB_DEPENDS= libmpdclient.so:audio/libmpdclient
-
-.include <bsd.port.mk>
+++ /dev/null
-Gather some system information and show it in this statusbar program, not tied to any Window Manager, terminal multiplexer, etc.
+++ /dev/null
-#!/usr/bin/env bash
-
-# Copyright 08/26/2016
-# Aaron Caffrey https://github.com/wifiextender
-
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-
-cd work/pinky-bar-*
-
-chmod +x bootstrap
-./bootstrap freebsd
-
-mkdir -p -m 755 '/usr/local/share/icons/xbm_icons'
-install -D -m644 xbm_icons/* '/usr/local/share/icons/xbm_icons'
-
-cd ../..
+++ /dev/null
-#!/usr/bin/env bash
-
-# Copyright 08/26/2016
-# Aaron Caffrey https://github.com/wifiextender
-
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-
-make makesum
+++ /dev/null
-#!/usr/bin/env bash
-
-# Copyright 08/26/2016
-# Aaron Caffrey https://github.com/wifiextender
-
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-
-echo
-echo
-echo 'Please read the README'
-echo 'https://github.com/wifiextender/pinky-bar/blob/master/README.md'
-echo
-echo
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-/* Functions shared between different operating
- * zyztemz or are short enough that doesn't meet the
- * 100 lines requirement to be put in standalone module */
-
-#include "config.h" /* Auto-generated */
-
-#include <ctype.h>
-
-#include <sys/statvfs.h>
-#include <sys/utsname.h>
-
-#if defined(__linux__)
-#include <glob.h>
-#endif /* __linux__ */
-
-#if defined (HAVE_X11_XLIB_H)
-#include <X11/Xlib.h>
-#endif
-
-#if defined(HAVE_CDIO_CDIO_H)
-#include <cdio/cdio.h>
-#include <cdio/mmc.h>
-#endif /* HAVE_CDIO_CDIO_H */
-
-#include "include/headers.h"
-
-#if defined(__FreeBSD__)
-#include "include/freebzd.h"
-#endif /* __FreeBSD__ */
-
-#if defined(__OpenBSD__)
-#include "include/openbzd.h"
-#endif /* __OpenBSD__ */
-
-
-#if defined(__linux__)
-static uint_fast16_t glob_packages(const char *);
-#endif /* __linux__ */
-
-void
-exit_with_err(const char *str1, const char *str2) {
- FPRINTF("%s %s\n", str1, str2);
- exit(EXIT_FAILURE);
-}
-
-
-#if defined(__linux__)
-void
-get_temp(const char *str1, char *str2) {
- uint_least32_t temp = 0;
- FILE *fp;
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, str1, SCAN_ULINT, &temp);
-#pragma GCC diagnostic pop
-
- if (99999 < temp) { /* > 99C */
- FILL_ARR(str2, ULINT, temp / 10000);
- } else {
- FILL_ARR(str2, ULINT, ((9999 < temp) ?
- temp / 1000 : temp / 100)); /* > 9C || < 9C */
- }
-}
-
-#endif /* __linux__ */
-
-#if defined(__FreeBSD__)
-void
-get_temp(char *str1, uint_least32_t temp) {
- if (9999 < temp) { /* > 99C */
- FILL_ARR(str1, ULINT, temp / 1000);
- } else {
- FILL_ARR(str1, ULINT, ((999 < temp) ?
- temp / 100 : temp / 10)); /* > 9C || < 9C */
- }
-}
-#endif /* __FreeBSD__ */
-
-
-void
-check_fan_vals(char *str1, uint_fast16_t *rpm, uint8_t iterz) {
- uint8_t x = 0, y = 0;
- char buffer[VLA];
- char *all_fans = buffer;
-
- for (x = 0; x < iterz; x++) {
- if (0 != rpm[x]) {
- GLUE2(all_fans, UFINT" ", rpm[x]);
- } else {
- ++y; /* non-spinning | removed | failed fan */
- }
- }
- FILL_STR_ARR(1, str1, (y != x ? buffer : NOT_FOUND));
-
-}
-
-
-void
-get_ssd(char *str1, uint8_t num) {
- uintmax_t val = 0;
- struct statvfs ssd;
- memset(&ssd, 0, sizeof(struct statvfs));
-
- if (-1 == (statvfs(getenv("HOME"), &ssd))) {
- FUNC_FAILED("statvfs()");
- }
-
- switch(num) {
- case 1:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)(ssd.f_blocks * ssd.f_bsize) / GB, "GB");
- break;
- case 2:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)(ssd.f_bfree * ssd.f_bsize) / GB, "GB");
- break;
- case 3:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)(ssd.f_bavail * ssd.f_bsize) / GB, "GB");
- break;
- case 4:
- {
- val = (uintmax_t)((
- ssd.f_blocks - ssd.f_bfree) * ssd.f_bsize) / GB;
- FILL_UINT_ARR(str1, val);
- }
- break;
- }
-}
-
-
-void
-get_kernel(char *str1, uint8_t num) {
- struct utsname KerneL;
- memset(&KerneL, 0, sizeof(struct utsname));
-
- if (-1 == (uname(&KerneL))) {
- FUNC_FAILED("uname()");
- }
-
- switch(num) {
- case 1:
- FILL_STR_ARR(1, str1, KerneL.sysname);
- break;
- case 2:
- FILL_STR_ARR(1, str1, KerneL.nodename);
- break;
- case 3:
- FILL_STR_ARR(1, str1, KerneL.release);
- break;
- case 4:
- FILL_STR_ARR(1, str1, KerneL.version);
- break;
- case 5:
- FILL_STR_ARR(1, str1, KerneL.machine);
- break;
- case 6:
- FILL_STR_ARR(2, str1, KerneL.sysname, KerneL.release);
- break;
- }
-}
-
-
-#if defined(__linux__)
-/* Source (my improved screenfetch-c fork):
- * https://github.com/wifiextender/screenfetch-c/blob/master/src/plat/linux/detect.c */
-static uint_fast16_t
-glob_packages(const char *str1) {
- uint_fast16_t packs_num = 0;
- glob_t gl;
-
- if (0 == (glob(str1, GLOB_NOSORT, NULL, &gl))) {
- packs_num = gl.gl_pathc;
- } else {
- exit_with_err("Could not traverse", str1);
- }
- globfree(&gl);
-
- return packs_num;
-}
-#endif /* __linux__ */
-
-
-/* Let the compiler strip the code
- * instead conditionally checking
- * each time the program is executed */
-void
-get_packs(char *str1) {
- uint_fast16_t packages = 0;
- FILE *pkgs_file;
-
-#if DISTRO == ARCHLINUX
- packages = glob_packages("/var/lib/pacman/local/*");
-
-#elif DISTRO == FRUGALWARE
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_POPEN(pkgs_file, "pacman-g2 -Q 2> /dev/null | wc -l", &packages);
-#pragma GCC diagnostic pop
-
-#elif DISTRO == DEBIAN
- packages = glob_packages("/var/lib/dpkg/info/*.list");
-
-#elif DISTRO == SLACKWARE
- packages = glob_packages("/var/log/packages/*");
-
-#elif DISTRO == GENTOO
- packages = glob_packages("/var/db/pkg/*/*");
-
-#elif DISTRO == RHEL
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_POPEN(pkgs_file, "rpm -qa 2> /dev/null | wc -l", &packages);
-#pragma GCC diagnostic pop
-
-#elif DISTRO == ANGSTROM
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_POPEN(pkgs_file, "opkg list-installed 2> /dev/null | wc -l", &packages);
-#pragma GCC diagnostic pop
-
-#elif DISTRO == FREEBSD
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_POPEN(pkgs_file, "pkg info | wc -l", &packages);
-#pragma GCC diagnostic pop
-
-#elif DISTRO == OPENBSD
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_POPEN(pkgs_file, "pkg_info | wc -l", &packages);
-#pragma GCC diagnostic pop
-
-
-#endif
-
- FILL_ARR(str1, UFINT, packages);
-}
-
-
-void
-get_uptime(char *str1) {
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
- struct timespec tc = {0};
-#pragma GCC diagnostic pop
-
- uintmax_t now = 0;
-
-#if defined(__linux__)
- if (-1 == (clock_gettime(CLOCK_BOOTTIME, &tc))) {
- FUNC_FAILED("clock_gettime()");
- }
-
- now = (uintmax_t)tc.tv_sec;
-#else
- int mib[] = { CTL_KERN, KERN_BOOTTIME };
- time_t t;
- size_t len = sizeof(tc);
-
- if (0 != (sysctl(mib, 2, &tc, &len, NULL, 0))) {
- FUNC_FAILED("sysctl()");
- }
-
- if (-1 == (t = time(NULL))) {
- FUNC_FAILED("time()");
- }
-
- now = (uintmax_t)t - (uintmax_t)tc.tv_sec;
-#endif /* __linux__ */
-
- if (0 != (now / 86400)) { /* days */
- FILL_ARR(str1, FMT_UINT "d " FMT_UINT "h " FMT_UINT "m",
- (now / 86400),
- ((now / 3600) % 24),
- ((now / 60) % 60));
- return;
- }
- if (59 < (now / 60)) { /* hours */
- FILL_ARR(str1, FMT_UINT "h " FMT_UINT "m",
- ((now / 3600) % 24),
- ((now / 60) % 60));
- return;
- }
-
- FILL_ARR(str1, FMT_UINT "m", ((now / 60) % 60));
-}
-
-
-/* The `strftime' man page showed potential bugs */
-void
-get_taim(char *str1) {
- char time_str[VLA];
- time_t t;
- struct tm *taim;
-
- if (-1 == (t = time(NULL)) ||
- NULL == (taim = localtime(&t)) ||
- 0 == (strftime(time_str, VLA, "%I:%M %p", taim))) {
- exit_with_err(ERR, "time() or localtime() or strftime() failed");
- }
- FILL_STR_ARR(1, str1, time_str);
-}
-
-
-#if defined (HAVE_X11_XLIB_H)
-void
-set_status(const char *str1) {
- Display *display = XOpenDisplay(NULL);
-
- if (display) {
- XStoreName(display, DefaultRootWindow(display), str1);
- XSync(display, 0);
- XCloseDisplay(display);
-
- } else {
- exit_with_err(CANNOT_OPEN, "X server");
- }
-}
-#endif /* HAVE_X11_XLIB_H */
-
-
-#if !defined(HAVE_SENSORS_SENSORS_H) && !defined(__OpenBSD__)
-void
-get_fans(char *str1) {
- bool found_fans = true;
- char tempstr[VLA];
- uint8_t x = 0, y = 0, z = 0;
- uint_fast16_t rpm[MAX_FANS+1];
-
- memset(rpm, 0, sizeof(rpm));
-
-#if defined(__linux__)
- FILE *fp;
- for (x = 1; x < MAX_FANS; x++, z++) {
- FILL_ARR(tempstr, FAN_FILE, x);
-
- if (NULL == (fp = fopen(tempstr, "r"))) {
- if (1 == x) { /* no system fans at all */
- FILL_STR_ARR(1, str1, NOT_FOUND);
- found_fans = false;
- }
- break;
- }
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_FSCANF(fp, UFINT, &rpm[z]);
-#pragma GCC diagnostic pop
- CLOSE_X(fp);
- }
-
-#else
-
- u_int fan[3];
- memset(fan, 0, sizeof(fan));
- size_t len = sizeof(fan);
-
- for (x = 0; x < MAX_FANS; x++, z++) {
- FAN_STR(tempstr, x);
- memset(fan, 0, len);
-
- if (0 != (sysctlbyname(tempstr, &fan, &len, NULL, 0))) {
- if (0 == x) { /* no system fans at all */
- FILL_STR_ARR(1, str1, NOT_FOUND);
- found_fans = false;
- }
- break;
- }
- rpm[x] = (uint_fast16_t)fan[0];
- }
-
-#endif /* __linux__ */
-
- if (found_fans) {
- check_fan_vals(str1, rpm, z);
- }
-}
-#endif /* !HAVE_SENSORS_SENSORS_H && !__OpenBSD__ */
-
-
-#if defined(HAVE_CDIO_CDIO_H)
-void
-get_dvd(char *str1) {
- CdIo_t *p_cdio = cdio_open(NULL, DRIVER_DEVICE);
- cdio_hwinfo_t hwinfo;
-
- FILL_STR_ARR(1, str1, "Null");
- if (NULL == p_cdio) {
- return;
- }
- if (true == (mmc_get_hwinfo(p_cdio, &hwinfo))) {
- FILL_STR_ARR(2, str1, hwinfo.psz_vendor, hwinfo.psz_model);
- }
- if (NULL != p_cdio) {
- cdio_destroy(p_cdio);
- }
-}
-#else
-
-#if defined(__linux__)
-void
-get_dvd(char *str1) {
- FILE *fp;
- char vendor[100], model[100];
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, DVD_VEND, "%s", vendor);
-#pragma GCC diagnostic pop
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, DVD_MODEL, "%s", model);
-#pragma GCC diagnostic pop
-
- FILL_STR_ARR(2, str1, vendor, model);
-}
-#endif /* __linux__ */
-
-#endif /* HAVE_CDIO_CDIO_H */
-
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
-void
-get_loadavg(char *str1) {
- double up[3];
- memset(up, 0, sizeof(up));
-
- if (-1 == getloadavg(up, 3)) {
- FUNC_FAILED("getloadavg()");
- }
- FILL_ARR(str1, "%.2f %.2f %.2f",
- (float)up[0], (float)up[1], (float)up[2]);
-}
-#endif /* __FreeBSD__ || __OpenBSD__ */
-
-
-void
-split_n_index(char *str1) {
- char *ptr = str1;
- for (; *ptr; ptr++) {
- if ((isspace((unsigned char) *ptr))) {
- break;
- }
- *str1++ = *ptr;
- }
- *str1 = '\0';
-}
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include "config.h" /* Auto-generated */
-
-#include "include/headers.h"
-#include "prototypes/cpu.h"
-
-#if defined(__FreeBSD__)
-#include "include/freebzd.h"
-#endif /* __FreeBSD__ */
-
-#if defined(__OpenBSD__)
-#include "include/openbzd.h"
-#endif /* __OpenBSD__ */
-
-void
-get_cpu(char *str1) {
- static uintmax_t previous_total = 0, previous_idle = 0;
- uintmax_t total = 0, percent = 0, diff_total = 0, diff_idle = 0;
- uintmax_t cpu_active[LOOP_ITERZ];
- uint8_t x = 0;
-
- memset(cpu_active, 0, sizeof(cpu_active));
-
-#if defined(__FreeBSD__)
- size_t len = sizeof(cpu_active);
- SYSCTLVAL("kern.cp_time", &cpu_active);
-#endif /* __FreeBSD__ */
-
-#if defined(__OpenBSD__)
- int mib[] = { CTL_KERN, KERN_CPTIME };
- size_t len = sizeof(cpu_active);
- SYSCTLVAL(mib, 2, &cpu_active, &len);
-#endif /* __OpenBSD__ */
-
-#if defined(__linux__)
- FILE *fp = fopen("/proc/stat", "r");
- CHECK_FP(fp);
-
- /* Some kernels will produce 7, 8 and 9 columns
- * We rely on 10, refer to `man proc' for more details */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- if (EOF == (fscanf(fp, "%*s " FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT,
- &cpu_active[0], &cpu_active[1], &cpu_active[2], &cpu_active[3],
- &cpu_active[4], &cpu_active[5], &cpu_active[6], &cpu_active[7],
- &cpu_active[8], &cpu_active[9]))) {
- CLOSE_X(fp);
- exit_with_err(ERR, "Upgrade to a newer kernel");
- }
-#pragma GCC diagnostic pop
- CLOSE_X(fp);
-#endif /* __linux__ */
-
- for (x = 0; x < LOOP_ITERZ; x++) {
- total += cpu_active[x];
- }
-
- diff_total = total - previous_total;
- diff_idle = cpu_active[IDLE_NUM] - previous_idle;
-
- previous_total = total;
- previous_idle = cpu_active[IDLE_NUM];
-
- percent = 0;
- if (0 != diff_total) {
- percent = ((uintmax_t)TICKZ * (diff_total - diff_idle)) / diff_total;
- }
-
- FILL_UINT_ARR(str1, percent);
-}
-
-
-void
-get_cores_load(char *str1) {
- static uintmax_t previous_total[MAX_CORES], previous_idle[MAX_CORES];
- static bool test_flag = false;
- uint8_t x = 0, y = 0, z = 0;
- uintmax_t percent[MAX_CORES], diff_total[MAX_CORES], core_active[MAX_CORES][LOOP_ITERZ];
- uintmax_t diff_idle[MAX_CORES], total[MAX_CORES];
- char buf[VLA], temp[VLA];
- char *all = temp;
-
- memset(percent, 0, sizeof(percent));
- memset(diff_total, 0, sizeof(diff_total));
- memset(diff_idle, 0, sizeof(diff_idle));
- memset(total, 0, sizeof(total));
- memset(core_active, 0, sizeof(core_active));
-
- if (false == test_flag) {
- memset(previous_idle, 0, sizeof(previous_idle));
- memset(previous_total, 0, sizeof(previous_total));
- }
-
-#if defined(__FreeBSD__)
- size_t len = sizeof(core_active);
- SYSCTLVAL("kern.cp_times", &core_active);
-#endif /* __FreeBSD__ */
-
-#if defined(__OpenBSD__)
- uintmax_t ncpu = 0;
- int mib[] = { CTL_KERN, KERN_CPTIME2, 0 };
- int mib2[] = { CTL_HW, HW_NCPU };
- size_t len = sizeof(core_active), len2 = sizeof(ncpu);
-
- SYSCTLVAL(mib2, 2, &ncpu, &len2);
- for (x = 0; x < ncpu; x++, mib[2]++) {
- if (0 != (sysctl(mib, 3, &core_active[x], &len, NULL, 0))) {
- break;
- }
- }
-#endif /* __OpenBSD__ */
-
-#if defined(__linux__)
- FILE *fp = fopen("/proc/stat", "r");
- CHECK_FP(fp);
-
- if (NULL == fgets(buf, VLA, fp)) {
- CLOSE_X(fp);
- exit_with_err(ERR, "reached /proc/stat EOF");
- }
-
- for (x = 0; x < MAX_CORES; x++, z++) {
- if (NULL == fgets(buf, VLA, fp)) {
- CLOSE_X(fp);
- exit_with_err(ERR, "reached /proc/stat EOF");
- }
-
- if ('c' != buf[0] && 'p' != buf[1] && 'u' != buf[2]) {
- break;
- }
-
- if (EOF == (sscanf(buf, "%*s " FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT,
- &core_active[x][0], &core_active[x][1], &core_active[x][2], &core_active[x][3],
- &core_active[x][4], &core_active[x][5], &core_active[x][6], &core_active[x][7],
- &core_active[x][8], &core_active[x][9]))) {
- CLOSE_X(fp);
- exit_with_err(ERR, "Upgrade to a newer kernel");
- }
- }
- CLOSE_X(fp);
-
- for (x = 0; x < z; x++) {
-
-#else /* FreeBSD || OpenBSD */
- for (x = 0; x < MAX_CORES; x++) {
- if (0 == core_active[x][0] && 0 ==
- core_active[x][1] && 0 ==
- core_active[x][2]) {
- break;
- }
-#endif /* __linux__ */
-
- for (y = 0; y < LOOP_ITERZ; y++) {
- total[x] += core_active[x][y];
- }
-
- diff_total[x] = total[x] - previous_total[x];
- diff_idle[x] = core_active[x][IDLE_NUM] - previous_idle[x];
-
- previous_total[x] = total[x];
- previous_idle[x] = core_active[x][IDLE_NUM];
-
- percent[x] = 0;
- if (0 != diff_total[x]) {
- percent[x] = ((uintmax_t)TICKZ * (diff_total[x] - diff_idle[x]))
- / diff_total[x];
- }
-
- GLUE2(all, FMT_UINT"%% ", percent[x]);
- }
- test_flag = true;
-
- FILL_STR_ARR(1, str1, temp);
-}
-
-
-/* Taken from the gcc documentation
- * https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
- *
- * other useful resources:
- * http://www.felixcloutier.com/x86/RDTSC.html
- * http://ref.x86asm.net/coder32.html#x0F31
-*/
-
-/* Not going to test for i486 and i586 */
-#if defined(__i386__) || defined(__i686__)
-static __inline__ uintmax_t
-rdtsc(void) {
- uintmax_t x = 0;
- __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (x));
- return x;
-}
-
-void
-get_cpu_clock_speed(char *str1) {
- uintmax_t x = 0, y = 0, z[2];
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
- struct timespec start = {0}, stop = {0}, tc = {0};
-#pragma GCC diagnostic pop
-
- tc.tv_nsec = TICKZ * 1000000L;
-
- x = rdtsc();
- if (-1 == (clock_gettime(CLOCK_MONOTONIC, &start))) {
- FUNC_FAILED("clock_gettime()");
- }
- z[0] = (uintmax_t)(start.tv_nsec - start.tv_sec);
-
- if (-1 == (nanosleep(&tc, NULL))) {
- FUNC_FAILED("nanosleep()");
- }
-
- y = rdtsc();
- if (-1 == (clock_gettime(CLOCK_MONOTONIC, &stop))) {
- FUNC_FAILED("clock_gettime()");
- }
- z[1] = (uintmax_t)(stop.tv_nsec - stop.tv_sec);
-
- if (0 != (z[1] - z[0])) {
- FILL_ARR(str1, FMT_UINT " MHz",
- (1000 * (y - x) / (z[1] - z[0])));
- }
-}
-
-
-#elif defined(__x86_64__)
-static __inline__ uintmax_t
-rdtsc(void) {
- unsigned int tickhi = 0, ticklo = 0;
- __asm__ __volatile__ ("rdtsc" : "=a"(ticklo), "=d"(tickhi));
- return (((uintmax_t)tickhi << 32) | (uintmax_t)ticklo);
-}
-
-void
-get_cpu_clock_speed(char *str1) {
- uintmax_t x = 0, z = 0;
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
- struct timespec tc = {0};
-#pragma GCC diagnostic pop
-
- tc.tv_nsec = TICKZ * 1000000L;
-
- x = rdtsc();
- if (-1 == (nanosleep(&tc, NULL))) {
- FUNC_FAILED("nanosleep()");
- }
- z = rdtsc();
-
- FILL_ARR(str1, FMT_UINT " MHz", ((z - x) / 100000));
-}
-#endif
-
-
-#if defined(__i386__) || defined(__i686__) || defined(__x86_64__)
-void
-get_cpu_info(char *str1) {
- uint_fast16_t vend = 0, x = 0, z = 0, corez = 0, leafB = 0, bitz[2];
- uint_fast16_t eax = 0, ecx = 0, edx = 0, ebx = 0, eax_old = 0, leafs = 0;
- uint_fast16_t line_size = 0, regz = 0, clflu6 = 0, caches[3];
- char buffer[VLA], vend_id[13], vend_chars[17];
- char *all = buffer;
- bool got_leafB = false;
-
- memset(caches, 0, sizeof(caches));
- memset(bitz, 0, sizeof(bitz));
- FILL_STR_ARR(1, str1, "Null");
-
- CPU_REGS(0x00000000, vend, leafs); /* movl $0x00000000, %eax */
- if (0x00000001 > leafs) {
- return;
- }
- if (vend != AmD && vend != InteL) {
- return;
- }
-
- CPU_FEATURE(0x80000000, regz); /* movl $0x80000000, %eax */
- if (0x80000004 > regz) {
- return;
- }
- CPU_FEATURE(0x00000001, eax_old); /* movl $0x00000001, %eax */
-
- for (x = 0x80000002; x <= 0x80000004; x++) { /* movl $0x80000002, %esi */
- CPU_STR2(x, eax, ebx, ecx, edx); /* cmpl $0x80000004, %eax */
- memset(vend_chars, 0, sizeof(vend_chars));
-
- for (z = 0; z < 4; z++) {
- vend_chars[z] = (char)(eax >> (z * 8)); /* movl %eax, 0 */
- vend_chars[z+4] = (char)(ebx >> (z * 8)); /* movl %ebx, 4 */
- vend_chars[z+8] = (char)(ecx >> (z * 8)); /* movl %ecx, 8 */
- vend_chars[z+12] = (char)(edx >> (z * 8)); /* movl %edx, 12 */
- }
- vend_chars[16] = '\0';
- GLUE2(all, "%s", vend_chars);
- }
-
- CPU_ID_STR(0x00000000, ebx, ecx, edx); /* movl $0x00000000, %ebx */
- for (x = 0; x < 4; x++) {
- vend_id[x] = (char)(ebx >> (x * 8)); /* movl %ebx, 0 */
- vend_id[x+4] = (char)(edx >> (x * 8)); /* movl %edx, 4 */
- vend_id[x+8] = (char)(ecx >> (x * 8)); /* movl %ecx, 8 */
- }
- vend_id[12] = '\0';
-
- if (vend == AmD) {
- if (0x80000005 <= regz) {
- CPU_STR2(0x80000005, eax, ebx, ecx, edx); /* movl $0x80000005, %eax */
- caches[0] = SHFT2(ecx >> (3 * 8)); /* movl %ecx, 24 */
- }
- CPU_STR2(0x00000001, eax, ebx, ecx, edx); /* movl $0x00000001, %eax */
- corez = SHFT2(ebx >> (2 * 8)); /* movl %ebx, 16 */
- }
-
- if (vend == InteL) {
- if (0x0000000B <= leafs) {
- CPU_STR2(0x0000000B, eax, ebx, ecx, edx); /* movl $0x0000000B, %eax */
- corez = SHFT2(ebx); /* movl %ebx, 0 */
- leafB = SHFT2(edx); /* movl %edx, 0 */
- got_leafB = true;
-
- } else {
- if (0x00000004 <= leafs) {
- CPU_STR2(0x00000004, eax, ebx, ecx, edx); /* movl $0x00000004, %eax */
- corez = SHFT2(eax >> 26); /* movl %eax, 26 */
- }
- }
- }
-
- if (0x80000006 <= regz) {
- CPU_STR2(0x80000006, eax, ebx, ecx, edx); /* movl $0x80000006, %eax */
- /* L2, line size */
- caches[1] = (ecx >> (2 * 8)) & 0xffff; /* movl %ecx, 16 */
- caches[2] = SHFT2(ecx); /* movl %ecx, 0 */
- }
-
- if (0x80000008 <= regz) {
- CPU_STR2(0x80000008, eax, ebx, ecx, edx); /* movl $0x80000008, %eax */
- /* physical, virtual */
- bitz[0] = SHFT2(eax); /* movl %eax, 0 */
- bitz[1] = SHFT2(eax >> 8); /* movl %eax, 8 */
-
- if (vend == AmD) {
- corez = SHFT2(ecx) + 1; /* movl %ecx, 0 */
- }
- }
-
- CPU_STR2(0x00000001, eax, ebx, ecx, edx); /* movl $0x00000001, %eax */
- if ((edx & (1 << 19))) {
- clflu6 = SHFT2(ebx >> 8) * 8; /* movl %ebx, 8 */
- }
-
- FILL_ARR(str1,
- UFINT "x %s ID %s"
- " CLFLUSH/Line size " UFINT " " UFINT
- " L1/L2 caches KB " UFINT " " UFINT
- " Stepping " UFINT " Family " UFINT
- " Model " UFINT
- " Bits " UFINT " " UFINT
- " apicid " UFINT,
-
- /* cores, vendor, vendor id */
- corez, buffer, vend_id,
- /* clflush, line size */
- clflu6, caches[2],
- /* L1, L2 */
- caches[0], caches[1],
- /* stepping, family */
- SHFT(eax_old), (SHFT(eax_old >> 8) +
- ((IZMAX(eax_old)) ? SHFT2(eax_old >> 20) : 0)),
- /* model */
- (SHFT(eax_old >> 4) |
- ((IZMAX(eax_old)) ? ((eax_old >> 12) & 0xf0) : 0)),
- /* physical and virtual bits */
- bitz[0], bitz[1],
- /* apicid */
- (true == got_leafB) ? leafB : SHFT2(ebx >> 24)
- );
-}
-#endif
+++ /dev/null
-/*
- 08/16/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include "config.h" /* Auto-generated */
-
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <vm/vm_param.h>
-#include <devstat.h>
-
-#if GOT_APM == 1 && defined(HAVE_MACHINE_APM_BIOS_H)
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <machine/apm_bios.h>
-#endif /* GOT_APM && HAVE_MACHINE_APM_BIOS_H */
-
-#include "include/headers.h"
-#include "include/freebzd.h"
-
-
-void
-get_ram(char *str1, uint8_t num) {
- u_int total = 0, freeram = 0, inactive = 0, pagesize = 0;
- u_int cache = 0, bufferram = 0, dummy = 0;
- uintmax_t utotal = 0, used = 0, pz = 0;
- size_t len = sizeof(dummy);
-
- SYSCTLVAL("vm.stats.vm.v_page_size", &pagesize);
- SYSCTLVAL("vm.stats.vm.v_page_count", &total);
- SYSCTLVAL("vm.stats.vm.v_inactive_count", &inactive);
- SYSCTLVAL("vm.stats.vm.v_free_count", &freeram);
- SYSCTLVAL("vm.stats.vm.v_cache_count", &cache);
- SYSCTLVAL("vfs.bufspace", &bufferram);
-
- pz = (uintmax_t)pagesize;
- used = ((uintmax_t)total * pz - (uintmax_t)freeram * pz
- - (uintmax_t)inactive * pz
- - (uintmax_t)cache * pz - (uintmax_t)bufferram) / MB;
- utotal = ((uintmax_t)total * pz) / MB;
-
- switch(num) {
- case 1:
- FILL_ARR(str1, FMT_UINT "%s", utotal, "MB");
- break;
- case 2:
- FILL_ARR(str1, FMT_UINT "%s",
- ((uintmax_t)freeram * pz) / MB, "MB");
- break;
- case 3:
- FILL_ARR(str1, FMT_UINT "%s",
- ((uintmax_t)inactive * pz) / MB, "MB");
- break;
- case 4:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)bufferram / MB, "MB");
- break;
- case 5:
- FILL_UINT_ARR(str1, (used * 100) / utotal);
- break;
- }
-
-}
-
-
-void
-get_voltage(char *str1) {
- u_int vol0[3], vol1[3], vol2[3], vol3[3];
-
- memset(vol0, 0, sizeof(vol0));
- memset(vol1, 0, sizeof(vol1));
- memset(vol2, 0, sizeof(vol2));
- memset(vol3, 0, sizeof(vol3));
-
- size_t len = sizeof(vol0);
-
- SYSCTLVAL(VOLTAGE_FILE("0"), &vol0);
- SYSCTLVAL(VOLTAGE_FILE("1"), &vol1);
- SYSCTLVAL(VOLTAGE_FILE("2"), &vol2);
- SYSCTLVAL(VOLTAGE_FILE("3"), &vol3);
-
- FILL_ARR(str1, "%.2f %.2f %.2f %.2f",
- (float)vol0[0] / 1000.0f,
- (float)vol1[0] / 1000.0f,
- (float)vol2[0] / 1000.0f,
- (float)vol3[0] / 1000.0f);
-}
-
-
-void
-get_cpu_temp(char *str1) {
- u_int temp = 0;
- size_t len = sizeof(temp);
-
- SYSCTLVAL(CPU_TEMP, &temp);
- get_temp(str1, (uint_least32_t)temp);
-}
-
-
-void
-get_mobo_temp(char *str1) {
- u_int temp[3];
- memset(temp, 0, sizeof(temp));
- size_t len = sizeof(temp);
-
- SYSCTLVAL(MOBO_VAL("temp.1"), &temp);
- get_temp(str1, (uint_least32_t)temp[0]);
-}
-
-
-void
-get_mobo(char *str1) {
- char temp[VLA];
- size_t len = sizeof(temp);
-
- SYSCTLVAL(MOBO_VAL("%desc"), &temp);
- FILL_STR_ARR(1, str1, temp);
-}
-
-
-/*
- Couldn't add this option on my own.
- Used the following resources to make this function happen:
- http://ftp.stu.edu.tw/FreeBSD/branches/3.0-stable/src/libexec/rpc.rstatd/rstat_proc.c
- https://github.com/giampaolo/psutil/blob/master/psutil/arch/bsd/freebsd.c
- http://opensource.apple.com/source/net_snmp/net_snmp-16/net-snmp/agent/mibgroup/ucd-snmp/diskio.c
- https://searchcode.com/codesearch/view/29835031/
- http://fossies.org/linux/pcp/src/pmdas/freebsd/disk.c
- Had to use Valgrind since we allocate memory with malloc.
-*/
-void
-get_statio(char *str1, char *str2) {
- struct statinfo stats;
- struct device_selection *dev_select = NULL;
- struct devstat *d = NULL;
- long int select_generation = 0;
- int x = 0, num_devices = 0, num_selected = 0, num_selections = 0;
-
- FILL_STR_ARR(1, str1, "Null");
- if(0 != devstat_checkversion(NULL)) {
- return;
- }
-
- memset(&stats, 0, sizeof(struct statinfo));
- stats.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
- if (NULL == stats.dinfo) {
- return;
- }
-
- if(-1 == devstat_getdevs(NULL, &stats)) {
- goto error;
- }
-
- num_devices = stats.dinfo->numdevs;
- if (-1 == devstat_selectdevs(&dev_select, &num_selected, &num_selections,
- &select_generation, stats.dinfo->generation, stats.dinfo->devices, num_devices,
- NULL, 0, NULL, 0, DS_SELECT_ADD, 16, 0)) {
- goto error;
- }
-
- for (x = 0; x < 16; x++) {
- d = &stats.dinfo->devices[x];
- if (STREQ(str2, d->device_name)) {
-
- if (d->device_type != DEVSTAT_TYPE_DIRECT &&
- d->device_type != DEVSTAT_TYPE_IF_SCSI &&
- d->device_type != DEVSTAT_TYPE_IF_IDE) {
- break;
- }
-
- FILL_ARR(str1, "Read " FMT_UINT " MB, Written " FMT_UINT " MB",
- (uintmax_t)d->bytes[DEVSTAT_READ] / MB,
- (uintmax_t)d->bytes[DEVSTAT_WRITE] / MB);
- break;
- }
- }
-
-error:
- if (NULL != dev_select) {
- free(dev_select);
- }
- if (NULL != stats.dinfo) {
- if (stats.dinfo->mem_ptr) {
- free(stats.dinfo->mem_ptr);
- }
- free(stats.dinfo);
- }
- return;
-}
-
-
-/* https://www.freebsd.org/doc/handbook/acpi-overview.html
- ACPI_BATT_STAT_NOT_PRESENT
-*/
-#if GOT_APM == 1 && defined(HAVE_MACHINE_APM_BIOS_H)
-void
-get_battery(char *str1) {
- struct apm_info bstate;
- int fd = 0;
- uintmax_t dummy = 0;
-
- FILL_STR_ARR(1, str1, "Null");
- memset(&bstate, 0, sizeof(struct apm_info));
-
- if (0 != (fd = open("/dev/apm", O_RDONLY))) {
- return;
- }
- if (0 != (ioctl(fd, APMIO_GETINFO, &bstate))) {
- CLOSE_FD(fd);
- return;
- }
- CLOSE_FD(fd);
-
- dummy = (uintmax_t)bstate.ai_batt_life;
- FILL_UINT_ARR(str1, (101 < dummy ? 0 : dummy));
-}
-
-#else
-
-void
-get_battery(char *str1) {
- u_int dummy = 0;
- uint_least32_t perc = 0;
- size_t len = sizeof(dummy);
- SYSCTLVAL("hw.acpi.battery.life", &dummy);
-
- perc = (uint_least32_t)dummy;
- FILL_ARR(str1, ULINT, (101 < perc ? 0 : perc));
-}
-#endif /* GOT_APM && HAVE_MACHINE_APM_BIOS_H */
-
-
-void
-get_swapp(char *str1, uint8_t num) {
- struct xswdev xsw;
- u_int pagesize = 0, dummy = 0;
- uintmax_t total = 0, used = 0, pz = 0;
- int mib[20];
-
- memset(mib, 0, sizeof(mib));
- memset(&xsw, 0, sizeof(struct xswdev));
- size_t mibi = sizeof(mib) / sizeof(mib[0]);
- size_t len = sizeof(dummy), sisi = sizeof(struct xswdev);
-
- FILL_STR_ARR(1, str1, "0 MB");
- SYSCTLVAL("vm.stats.vm.v_page_size", &pagesize);
- pz = (uintmax_t)pagesize;
-
- if (0 != (sysctlnametomib("vm.swap_info", mib, &mibi))) {
- return;
- }
- if (0 != (sysctl(mib, (u_int)(mibi + 1), &xsw, &sisi, NULL, 0))) {
- return;
- }
- if (xsw.xsw_version != XSWDEV_VERSION) {
- return;
- }
- used = (uintmax_t)xsw.xsw_used;
- total = (uintmax_t)xsw.xsw_nblks;
-
- switch(num) {
- case 1:
- FILL_ARR(str1, FMT_UINT" %s", ((total * pz) / MB), "MB");
- break;
- case 2:
- FILL_ARR(str1, FMT_UINT" %s",
- (((total - used) * pz) / MB), "MB");
- break;
- case 3:
- FILL_ARR(str1, FMT_UINT" %s", ((used * pz) / MB), "MB");
- break;
- case 4:
- {
- if (0 != total) {
- FILL_ARR(str1, FMT_UINT"%%", (used * 100) / total);
- } else {
- FILL_STR_ARR(1, str1, "0 %");
- }
- }
- break;
- }
-}
+++ /dev/null
-/*
- 08/17/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef INCLUDE_FREEBZD_HEADERZ_H_
-#define INCLUDE_FREEBZD_HEADERZ_H_
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#define SYSCTLVAL(x, y) \
- if (0 != sysctlbyname(x, y, &len, NULL, 0)) { \
- FUNC_FAILED("sysctlbyname()"); \
- }
-
-#endif /* INCLUDE_FREEBZD_HEADERZ_H_ */
+++ /dev/null
-/*
- 07/29/2015, 07/17/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef CONSTANTS2_H_
-#define CONSTANTS2_H_
-
-#define KB 1024
-#define MB 1048576 /* 1024 * 1024 */
-#define GB 1073741824 /* MB * 1024 */
-#define Mb 131072 /* 1024 * 1024 / 8 */
-#define BYTES_TO_MB(x) (x/2/1024) /* block bytes */
-
-#define FMT_UINT "%"PRIuMAX
-#define UFINT "%"PRIuFAST16
-#define ULINT "%"PRIuLEAST32
-#define USINT "%"PRIu8
-#define SCAN_UFINT "%"SCNuFAST16
-#define SCAN_ULINT "%"SCNuLEAST32
-#define SCAN_UINTX "%"PRIxMAX /* hex */
-
-/* stay away from va_list */
-#define FILL_ARR(x, z, ...) (snprintf(x, VLA, z, __VA_ARGS__))
-#define FILL_UINT_ARR(x, z) (FILL_ARR(x, FMT_UINT, z))
-#define FILL_STR_ARR(x, z, ...) (FILL_ARR(z, (1 == x ? "%s" : "%s %s"), __VA_ARGS__))
-#define GLUE2(x, z, ...) (x+=snprintf(x, VLA, z, __VA_ARGS__))
-
-/* temperature sensors */
-#define HWMON_DIR "/sys/class/hwmon/hwmon0"
-#define TEMPERATURE(x) (HWMON_DIR"/temp"x"_input")
-#define CPU_TEMP_FILE TEMPERATURE("1")
-#define MOBO_TEMP_FILE TEMPERATURE("2")
-
-/* motherboard model and vendor */
-#define MOTHERBOARD(x) ("/sys/class/dmi/id/board_"x)
-#define MOBO_NAME MOTHERBOARD("name")
-#define MOBO_VENDOR MOTHERBOARD("vendor")
-
-/* voltage and fans */
-#if defined(__linux__)
-#define VOLTAGE_FILE(x) (HWMON_DIR"/in"x"_input")
-#define FAN_FILE HWMON_DIR"/fan"UFINT"_input"
-#endif /* __linux__ */
-
-#if defined(__FreeBSD__)
-
-#if defined(MOBO_MODL) && defined(CPU_MODL)
-#define MOBO_VAL(x) MOBO_MODL "." x
-#define CPU_TEMP CPU_MODL
-#else
-#define MOBO_VAL(x) "dev.aibs.0."x
-#define CPU_TEMP "dev.cpu.0.temperature"
-
-#endif /* MOBO_MODL && CPU_MODL */
-
-#define VOLTAGE_FILE(x) MOBO_VAL("volt") "." x
-#define FAN_STR(x, z) (FILL_ARR(x, "%s"UFINT, MOBO_VAL("fan") ".", z))
-#endif /* __FreeBSD__ */
-
-/* battery reports */
-#define BATTERY_NUM(x, y, z) (FILL_ARR(x, "%s"USINT"%s%s", \
- "/sys/class/power_supply/BAT", y, "/charge_", z))
-#define BATTERY_USED(x, z) (BATTERY_NUM(x, z, "now"))
-#define BATTERY_TOTAL(x, z) (BATTERY_NUM(x, z, "full"))
-
-/* NIC model and vendor */
-#define NIC_NUM(x, y, z) (FILL_ARR(x, "%s%s%s%s", \
- "/sys/class/net/", y, "/device/", z))
-#define NIC_VEND(x, z) (NIC_NUM(x, z, "vendor"))
-#define NIC_MODEL(x, z) (NIC_NUM(x, z, "device"))
-
-/* The cdrom/dvdrom vendor and model */
-#define DVD_DIR(x) ("/sys/class/block/sr0/device/"x)
-#define DVD_VEND DVD_DIR("vendor")
-#define DVD_MODEL DVD_DIR("model")
-
-/* exit with error */
-#define CANNOT_OPEN "Could not open"
-#define CANNOT_CLOSE "Could not close a file handle"
-#define CANNOT_OPEN_FP "Could not open a file handle"
-#define FSCANF_FAILED "fscanf() failed"
-#define ERR "Error:"
-#define NOT_FOUND "Not found, "
-#define FUNC_FAILED(x) (exit_with_err(ERR, x " failed"))
-#define RECOMPILE_WITH(x) (exit_with_err(ERR, "recompile the program --with-" x))
-
-/* Let the preprocessor Do Repeat Myself */
-#define CHECK_SSCANF(buf, x, z) \
- if (EOF == (sscanf(buf, x, z))) { \
- exit_with_err(ERR, "sscanf() EOF"); \
- }
-
-#define CHECK_FSCANF(fp, x, z) \
- if (EOF == (fscanf(fp, x, z))) { \
- exit_with_err(ERR, FSCANF_FAILED); \
- }
-
-#define CHECK_FP(fp) \
- if (NULL == fp) { \
- exit_with_err(ERR, CANNOT_OPEN_FP); \
- }
-
-#define CLOSE_X(fp) \
- if (EOF == (fclose(fp))) { \
- exit_with_err(ERR, CANNOT_CLOSE); \
- }
-
-#define OPEN_X(fp, x, y, z) \
- if (NULL == (fp = fopen(x, "r"))) { \
- exit_with_err(CANNOT_OPEN, x); \
- } \
- CHECK_FSCANF(fp, y, z); \
- CLOSE_X(fp);
-
-#define CHECK_POPEN(fp, x, packs) \
- if (NULL == (fp = popen(x, "r"))) { \
- exit_with_err(CANNOT_OPEN, x); \
- } \
- CHECK_FSCANF(fp, SCAN_UFINT, packs); \
- if (-1 == (pclose(fp))) { \
- exit_with_err(CANNOT_CLOSE, x); \
- }
-
-#define CLOSE_FD(fd) \
- if (-1 == (close(fd))) { \
- exit_with_err(ERR, CANNOT_CLOSE); \
- }
-
-/* How many fans to try for detection */
-#define MAX_FANS 20
-
-#define STREQ(x, z) (0 == (strcmp(x, z)))
-#define FPRINTF(...) (fprintf(stderr, __VA_ARGS__))
-
-#endif /* CONSTANTS2_H_ */
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef INCLUDE_HEADERZ_H_
-#define INCLUDE_HEADERZ_H_
-
-#include <time.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include <unistd.h>
-
-#include "options_constants.h"
-#include "functions_constants.h"
-#include "../prototypes/functions.h"
-#include "../prototypes/common.h"
-
-#endif /* INCLUDE_HEADERZ_H_ */
+++ /dev/null
-/*
- 09/03/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef NCURSES_COLOURS_H_
-#define NCURSES_COLOURS_H_
-
-
-#if WITH_COLOURS == 1
-#define PINK "^M"
-#define BLUE "^B"
-#define YELLOW "^Y"
-
-#else
-#define PINK ""
-#define BLUE ""
-#define YELLOW ""
-
-#endif /* WITH_COLOURS */
-
-#define NAME_VAL BLUE STR_SPEC " " PINK STR_SPEC /* STR1 STR2 */
-#define TEMP YELLOW STR_SPEC "C " /* 32C */
-#define FMT_KERN YELLOW KERN_ORIG /* Kernel Version */
-#define FMT_SONG PINK SONG_ORIG /* Song */
-
-
-#endif /* NCURSES_COLOURS_H_ */
+++ /dev/null
-/*
- 07/24/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef COLOURS_H_
-#define COLOURS_H_
-
-
-#if WITH_COLOURS == 1
-#define XBM_ICON(given_icon) "^i("ICONS_DIR"/"given_icon")"
-#define YELLOW "^fg(#f0c674)"
-#define BLUE "^fg(#1793D1)"
-#define PINK "^fg(#b294bb)"
-
-#define NAME_VAL BLUE STR_SPEC " " PINK STR_SPEC /* STR1 STR2 */
-#define TEMP YELLOW "%s" XBM_ICON("temp.xbm") " " /* 32C */
-#define FMT_KERN YELLOW KERN_ORIG /* Kernel Version */
-#define FMT_SONG PINK SONG_ORIG /* Song */
-
-#define CPU_STR XBM_ICON("cpu.xbm")
-#define RAM_STR XBM_ICON("mem.xbm")
-#define SSD_STR XBM_ICON("diskette.xbm")
-#define PKG_STR XBM_ICON("arch.xbm")
-#define VOLT_STR XBM_ICON("voltage.xbm")
-#define FANS_STR XBM_ICON("fan.xbm")
-#define MOBO_STR XBM_ICON("mobo.xbm")
-#define VOL_STR XBM_ICON("vol.xbm")
-#define TIME_STR XBM_ICON("clock.xbm")
-#define MPD_ICON XBM_ICON("mpd.xbm")
-#define NET_STR XBM_ICON("net.xbm")
-#define SPEED_STR XBM_ICON("net.xbm")
-#define STATIO_STR XBM_ICON("statio.xbm")
-#define BATT_STR XBM_ICON("bat.xbm")
-#define LOAD_STR CPU_STR
-#define UP_STR XBM_ICON("uptime.xbm")
-
-/* tmux or other program that can spice
- * the output on it's own */
-#else
-
-#define PINK ""
-#define NAME_VAL STR_SPEC " " STR_SPEC /* STR1 STR2 */
-#define TEMP STR_SPEC "C " /* 32C */
-#define FMT_KERN KERN_ORIG /* Kernel Version */
-#define FMT_SONG SONG_ORIG /* Song */
-
-#endif /* WITH_COLOURS */
-
-
-#endif /* COLOURS_H_ */
+++ /dev/null
-/*
- 09/08/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef INCLUDE_OPENBZD_HEADERZ_H_
-#define INCLUDE_OPENBZD_HEADERZ_H_
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#define SYSCTLVAL(w, x, y, z) \
- if (0 != (sysctl(w, x, y, z, NULL, 0))) { \
- FUNC_FAILED("sysctl()"); \
- }
-
-#endif /* INCLUDE_OPENBZD_HEADERZ_H_ */
+++ /dev/null
-/*
- 07/29/2015, 07/18/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef CONSTANTS_H_
-#define CONSTANTS_H_
-
-#define VLA 200
-#define WHOLE_MAIN_ARR_LEN VLA*16
-#define GLUE(x, z, ...) (x+=snprintf(x, WHOLE_MAIN_ARR_LEN, z, __VA_ARGS__))
-
-#if defined(__FreeBSD__)
-/* The clock ticks in FreeBSD are 133 */
-#define TICKZ 100
-#else
-#define TICKZ sysconf(_SC_CLK_TCK)
-#endif
-
-#include "options_generator.h"
-
-#define STR_SPEC "%s"
-#define SONG_ORIG STR_SPEC " "
-#define KERN_ORIG STR_SPEC " "
-
-#ifndef WITH_NCURSES
-#define WITH_NCURSES 6
-#endif
-#if defined (HAVE_X11_XLIB_H) || WITH_NCURSES == 1 || WITH_COLOURS == 0
-
-#define CPU_STR "CPU"
-#define RAM_STR "RAM"
-#define SSD_STR "SSD"
-#define PKG_STR "Pkgs"
-#define VOLT_STR "Voltage"
-#define FANS_STR "Fans/RPM"
-#define MOBO_STR "Mobo"
-#define VOL_STR "Volume"
-#define TIME_STR "Time"
-#define NET_STR "Used Net"
-#define STATIO_STR "Statio"
-#define SPEED_STR "Speed"
-#define BATT_STR "BATT"
-#define UP_STR "Up"
-#define LOAD_STR "Load/avg"
-
-#endif /* HAVE_X11_XLIB_H || WITH_NCURSES || WITH_COLOURS */
-
-
-#if defined (HAVE_X11_XLIB_H)
-#include "x11_colours.h"
-
-#elif WITH_NCURSES == 1
-#include "ncurses_colours.h"
-
-#else
-#include "non_x11_colours.h"
-
-#endif /* HAVE_X11_XLIB_H */
-
-
-/* options.c format constants */
-#define FMT NAME_VAL"%% " /* STR1 10% */
-#define FMT_TIME NAME_VAL /* Time 10:00 PM */
-#define FMT_MOBO FMT_TIME" " /* VEND NAME */
-#define FMT_CPU FMT_TIME"%% " /* CPU 10% */
-#define FMT_CORES FMT_TIME /* CPU varying */
-#define FMT_RAM FMT /* RAM 10% */
-#define FMT_RAM2 FMT_TIME" " /* RAM 10MB */
-#define FMT_SSD FMT /* SSD 10% */
-#define FMT_SSD2 FMT_RAM2 /* SSD 10MB */
-#define FMT_PKGS FMT_TIME" " /* Pkgs 123 */
-#define FMT_VOLT FMT_PKGS /* Voltage 1 2 3 4 */
-#define FMT_FANS FMT_TIME /* Fans varying */
-#define FMT_VOL FMT /* Volume 10% */
-#define FMT_NET FMT_PKGS /* Down 123 Up 123 */
-#define FMT_STATIO FMT_NET /* Read 123 Written 123 */
-#define FMT_CPUSPEED PINK STR_SPEC " " /* 1234 MHz */
-#define FMT_TEMP TEMP /* 32C */
-#define FMT_BATT FMT /* BATT 10% */
-#define FMT_UP FMT_TIME" " /* Up 10 min */
-#define FMT_LOAD FMT_TIME" " /* Load/avg 0.01 0.01 0.01 */
-
-
-#endif /* CONSTANTS_H_ */
+++ /dev/null
-/*
- 08/12/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef GENERATOR_H_
-#define GENERATOR_H_
-
-/* Employ the preprocessor */
-#define GET_N_FMT(func, ...) \
- get_##func(func); \
- GLUE(__VA_ARGS__);
-
-/* Remember vanilla ice ? */
-#define SLEEP_SLEEP_BABY(x) \
- tc.tv_nsec = x; \
- if (-1 == (nanosleep(&tc, NULL))) { \
- printf("%s\n", "Error: nanosleep() failed"); \
- return EXIT_FAILURE; \
- }
-
-#define GET_NET_N_FMT(arg1, arg2, arg3, ...) \
- get_net(arg1, arg2, arg3); \
- if (2 == arg3) { \
- SLEEP_SLEEP_BABY(850000000L); \
- get_net(arg1, arg2, arg3); \
- } \
- GLUE(__VA_ARGS__);
-
-/* Let the platform ticks decide how much
- * time is needed to sleep
- * 100 in linux and openbsd, 133 in freebsd */
-#define NEW_CPU_LABEL(lbl, declareVar, useVar, ...) \
- case lbl: \
- { \
- declareVar; \
- get_##useVar(useVar); \
- SLEEP_SLEEP_BABY(sysconf(_SC_CLK_TCK) * 1000000L); \
- GET_N_FMT(useVar, arguments->all, __VA_ARGS__, useVar); \
- } \
- break;
-
-#define NEW_LABEL(lbl, declareVar, useVar, ...) \
- case lbl: \
- { \
- declareVar; \
- GET_N_FMT(useVar, arguments->all, __VA_ARGS__, useVar); \
- } \
- break;
-
-#define NEW_NET_LABEL(lbl, declareVar, useVar, num, ...) \
- case lbl: \
- { \
- declareVar; \
- GET_NET_N_FMT(useVar, arg, num, arguments->all, __VA_ARGS__, useVar); \
- } \
- break;
-
-#define NEW_ARG_LABEL(lbl, declareVar, useVar, ...) \
- case lbl: \
- { \
- declareVar; \
- get_##useVar(useVar, arg); \
- GLUE(arguments->all, __VA_ARGS__, useVar); \
- } \
- break;
-
-#define NEW_MPD_LABEL(lbl, declareVar, useVar, num) \
- case lbl: \
- { \
- declareVar = ""; \
- get_song(useVar, num); \
- GLUE(arguments->all, FMT_SONG, useVar); \
- } \
- break;
-
-#define LABEL_WITH_NUM_GENERATOR(func, lbl, declareVar, useVar, num, ...) \
- case lbl: \
- { \
- declareVar; \
- get_##func(useVar, num); \
- GLUE(arguments->all, __VA_ARGS__, useVar); \
- } \
- break;
-
-#define NEW_RAM_LABEL(...) \
- LABEL_WITH_NUM_GENERATOR(ram, __VA_ARGS__);
-
-#define NEW_SSD_LABEL(...) \
- LABEL_WITH_NUM_GENERATOR(ssd, __VA_ARGS__);
-
-#define NEW_KERNEL_LABEL(...) \
- LABEL_WITH_NUM_GENERATOR(kernel, __VA_ARGS__);
-
-#define NEW_SWAPP_LABEL(...) \
- LABEL_WITH_NUM_GENERATOR(swapp, __VA_ARGS__);
-
-/* Fire the preprocessor */
-
-
-#endif /* GENERATOR_H_ */
+++ /dev/null
-/*
- 07/24/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef X_COLOURS_H_
-#define X_COLOURS_H_
-
-
-/* The dwm colours are specified
- * in your dwm config.h
-*/
-#if WITH_COLOURS == 1
-#define PINK "\x0b"
-#define BLUE "\x0a"
-#define YELLOW "\x09"
-
-#else
-#define PINK ""
-#define BLUE ""
-#define YELLOW ""
-
-#endif /* WITH_COLOURS */
-
-#define NAME_VAL BLUE STR_SPEC " " PINK STR_SPEC /* STR1 STR2 */
-#define TEMP YELLOW STR_SPEC "C " /* 32C */
-#define FMT_KERN YELLOW KERN_ORIG /* Kernel Version */
-#define FMT_SONG PINK SONG_ORIG /* Song */
-
-
-#endif /* X_COLOURS_H_ */
+++ /dev/null
-/*
- 07/18/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-/* The pragma directives are here
- * to mute the gcc twisted vision,
- * and clangs inabillity to distinguish
- * C from C++
- *
- * https://llvm.org/bugs/show_bug.cgi?id=21689
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
- *
- * Do not add any -Wno flags just to mute the compilers snafus
- * */
-
-#include "config.h" /* Auto-generated */
-
-#include <sys/sysinfo.h>
-
-#if defined(HAVE_SENSORS_SENSORS_H)
-#include <sensors/sensors.h>
-#endif /* HAVE_SENSORS_SENSORS_H */
-
-#include "include/headers.h"
-
-void
-get_ram(char *str1, uint8_t num) {
- uintmax_t used = 0, total = 0;
- struct sysinfo mem;
- memset(&mem, 0, sizeof(struct sysinfo));
-
- if (-1 == (sysinfo(&mem))) {
- FUNC_FAILED("sysinfo()");
- }
-
- switch(num) {
- case 1:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)mem.totalram / MB, "MB");
- break;
- case 2:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)mem.freeram / MB, "MB");
- break;
- case 3:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)mem.sharedram / MB, "MB");
- break;
- case 4:
- FILL_ARR(str1, FMT_UINT "%s",
- (uintmax_t)mem.bufferram / MB, "MB");
- break;
- case 5:
- {
- total = (uintmax_t) mem.totalram / MB;
- used = (uintmax_t) (mem.totalram - mem.freeram -
- mem.bufferram - mem.sharedram) / MB;
- FILL_UINT_ARR(str1, (used * 100) / total);
- }
- break;
- }
-}
-
-
-void
-get_ssd_model(char *str1, char *str2) {
- FILE *fp;
- char model[VLA];
- FILL_ARR(model, "%s%s%s", "/sys/block/", str2, "/device/model");
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, model, "%[^\n]", model);
-#pragma GCC diagnostic pop
-
- FILL_STR_ARR(1, str1, model);
-}
-
-
-void
-get_loadavg(char *str1) {
- struct sysinfo up;
- memset(&up, 0, sizeof(struct sysinfo));
-
- if (-1 == (sysinfo(&up))) {
- FUNC_FAILED("sysinfo()");
- }
- FILL_ARR(str1, "%.2f %.2f %.2f",
- (float)up.loads[0] / 65535.0f,
- (float)up.loads[1] / 65535.0f,
- (float)up.loads[2] / 65535.0f);
-}
-
-/* My inital attempt was to make this code FreeBSD exclusive as the
- * sensors parsing there is much more difficult than it is in linux.
- */
-#if defined(HAVE_SENSORS_SENSORS_H)
-void
-match_feature(char *str1, uint8_t num) {
-#if SENSORS_API_VERSION >= 0x400 && SENSORS_API_VERSION <= 0x499
- const sensors_chip_name *chip;
- const sensors_feature *features;
- const sensors_subfeature *subfeatures;
- char buffer[VLA];
- char *label = NULL, *all = buffer;
- double value = 0.0;
- int nr = 0, nr2 = 0, nr3 = 0;
- uint8_t x = 0, y = 0, z = 0, dummy = 0;
- uint_fast16_t rpm[MAX_FANS+1];
- bool found_fans = false;
- const char *temp_sens[] = { "MB Temperature", "CPU Temperature" };
-
- if (3 == num) {
- memset(rpm, 0, sizeof(rpm));
- }
-
- /* In case I need to parse the rest
- * min, max, input values */
- /* struct stats_pwr_in *st_pwr_in_i; */
- /* struct stats_pwr_temp *st_pwr_temp_i; */
- /* struct stats_pwr_fan *st_pwr_fan_i; */
-
- FILL_STR_ARR(1, str1, "Null");
- if (0 != (sensors_init(NULL))) {
- FUNC_FAILED("sensors_init()");
- }
-
- while (NULL != (chip = sensors_get_detected_chips(NULL, &nr))) {
- nr2 = 0;
- while (NULL != (features = sensors_get_features(chip, &nr2))) {
- nr3 = 0;
- while (NULL != (subfeatures = sensors_get_all_subfeatures(chip, features, &nr3))) {
- switch(subfeatures->type) {
-
- case SENSORS_SUBFEATURE_IN_INPUT:
- {
- if (1 == num) {
- if (0 != (sensors_get_value(chip, subfeatures->number, &value))) {
- break;
- }
- GLUE2(all, "%.2f ", (float)value);
- }
- }
- break;
-
- case SENSORS_SUBFEATURE_TEMP_INPUT:
- {
- if (2 == num || 4 == num) {
- dummy = (2 == num ? 0 : 1);
- if (0 != (sensors_get_value(chip, subfeatures->number, &value))) {
- break;
- }
- if (NULL == (label = sensors_get_label(chip, features))) {
- break;
- }
- if (STREQ(temp_sens[dummy], label)) {
- FILL_ARR(str1, UFINT, (uint_fast16_t)value);
- }
- if (NULL != label) {
- free(label);
- }
- }
- }
- break;
-
- case SENSORS_SUBFEATURE_FAN_INPUT:
- {
- if (3 == num) {
- if (0 != (sensors_get_value(chip, subfeatures->number, &value))) {
- break;
- }
- if (MAX_FANS != z) {
- rpm[z++] = (uint_fast16_t)value;
- }
- found_fans = true;
- }
- }
- break;
-
- default:
- continue;
- }
- }
- }
- }
- sensors_cleanup();
-
- if (1 == num && '\0' != buffer[0]) {
- size_t len = strlen(buffer);
- buffer[len-1] = '\0';
-
- FILL_STR_ARR(1, str1, buffer);
- return;
- }
-
- if (found_fans) {
- check_fan_vals(str1, rpm, z);
- }
-
-#else
- exit_with_err(ERR, "The version of your sensors API is not supported by this program.");
-#endif /* SENSORS_API_VERSION >= 0x400 && SENSORS_API_VERSION <= 0x499 */
-}
-
-
-void
-get_voltage(char *str1) {
- match_feature(str1, 1);
-}
-
-
-void
-get_mobo_temp(char *str1) {
- match_feature(str1, 2);
-}
-
-
-void
-get_fans(char *str1) {
- match_feature(str1, 3);
-}
-
-
-void
-get_cpu_temp(char *str1) {
- match_feature(str1, 4);
-}
-
-
-#else /* fall back */
-void
-get_voltage(char *str1) {
- float voltage[4];
- FILE *fp;
- uint8_t x = 0;
- memset(voltage, 0, sizeof(voltage));
-
- const char *voltage_files[] = {
- VOLTAGE_FILE("0"),
- VOLTAGE_FILE("1"),
- VOLTAGE_FILE("2"),
- VOLTAGE_FILE("3")
- };
-
- for (x = 0; x < 4; x++) {
- if (NULL == (fp = fopen(voltage_files[x], "r"))) {
- exit_with_err(CANNOT_OPEN, voltage_files[x]);
- }
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_FSCANF(fp, "%f", &voltage[x]);
-#pragma GCC diagnostic pop
- CLOSE_X(fp);
-
- voltage[x] /= 1000.0f;
- }
- FILL_ARR(str1, "%.2f %.2f %.2f %.2f",
- voltage[0], voltage[1], voltage[2], voltage[3]);
-}
-
-
-void
-get_mobo_temp(char *str1) {
- get_temp(MOBO_TEMP_FILE, str1);
-}
-
-
-void
-get_cpu_temp(char *str1) {
- get_temp(CPU_TEMP_FILE, str1);
-}
-#endif /* HAVE_SENSORS_SENSORS_H */
-
-
-void
-get_mobo(char *str1) {
- FILE *fp;
- char vendor[100], name[100];
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, MOBO_VENDOR, "%s", vendor);
-#pragma GCC diagnostic pop
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, MOBO_NAME, "%s", name);
-#pragma GCC diagnostic pop
-
- FILL_STR_ARR(2, str1, vendor, name);
-}
-
-
-void
-get_statio(char *str1, char *str2) {
- uintmax_t statio[7];
- char stat_file[VLA];
- FILL_ARR(stat_file, "%s%s%s", "/sys/block/", str2, "/stat");
-
- memset(statio, 0, sizeof(statio));
-
- FILE *fp = fopen(stat_file, "r");
- CHECK_FP(fp);
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- if (EOF == (fscanf(fp, FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT,
- &statio[0], &statio[1], &statio[2], &statio[3],
- &statio[4], &statio[5], &statio[6]))) {
- CLOSE_X(fp);
- exit_with_err(ERR, "reading the stat file failed");
- }
-#pragma GCC diagnostic pop
- CLOSE_X(fp);
-
- FILL_ARR(str1, "Read " FMT_UINT " MB, Written " FMT_UINT " MB",
- BYTES_TO_MB(statio[2]), BYTES_TO_MB(statio[6]));
-}
-
-
-/* Thanks to https://bugzilla.kernel.org/show_bug.cgi?id=83411 */
-void
-get_battery(char *str1) {
- uintmax_t used = 0, total = 0, percent = 0;
- uint8_t num = 0;
- char temp[VLA];
- BATTERY_TOTAL(temp, num);
-
- FILE *fp = fopen(temp, "r");
- if (NULL == fp) {
- num = 1;
- BATTERY_TOTAL(temp, num);
-
- if (NULL == (fp = fopen(temp, "r"))) {
- exit_with_err(CANNOT_OPEN, "BAT0 and BAT1");
- }
- }
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- CHECK_FSCANF(fp, FMT_UINT, &total);
-#pragma GCC diagnostic pop
- CLOSE_X(fp);
-
- BATTERY_USED(temp, num);
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, temp, FMT_UINT, &used);
-#pragma GCC diagnostic pop
-
- percent = 0;
- if (0 != total) {
- percent = (used * 100) / total;
- }
- FILL_UINT_ARR(str1, percent);
-}
+++ /dev/null
-/*
- Copyright 02/22/2015, 07/18/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include "config.h" /* Auto-generated */
-#include "include/headers.h"
-#include "prototypes/options.h"
-
-int main(int argc, char *argv[]) {
-
- if (1 == argc) {
- FPRINTF("%s\n", "Try --help or --usage for more information.");
- return EXIT_FAILURE;
- }
- if (-1 == (sysconf(_SC_CLK_TCK))) {
- FPRINTF("%s\n", "Error: sysconf() failed");
- return EXIT_FAILURE;
- }
-
- char combined[WHOLE_MAIN_ARR_LEN];
- char *all = combined;
- parse_opts(argc, argv, all);
-
- if ('\0' != combined[0]) {
-#if defined (HAVE_X11_XLIB_H)
- set_status(combined);
-#else
- fprintf(stdout, "%s\n", combined);
-#endif
- }
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-/*
- 09/03/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-
- Compile with:
- gcc -std=c99 -D_POSIX_C_SOURCE=200112L -Wall -Wextra -O2 ncurses.c -o pinky_curses -lncurses
- BSD users should type -D_DEFAULT_SOURCE instead.
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <ctype.h>
-
-#include <locale.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include <ncurses.h>
-
-#define VLA 1000
-#define EIGHT 8
-#define WIN95 stdscr
-
-#define RESTORE_CURSOR() \
- echo(); \
- nl(); \
- curs_set(TRUE); \
- endwin();
-
-void unuglify(char *);
-void sighandler(int num);
-void init_da_handler(void);
-
-volatile sig_atomic_t call_it_quits = 0;
-
-int main(void) {
- init_da_handler();
- if (NULL == (setlocale(LC_ALL, ""))) {
- return EXIT_FAILURE;
- }
-
- int16_t color_pair = 1, fg = 1, bg = 1, x = 0, z = 0;
- int32_t old_x = 0, old_y = 0, new_y = 0, new_x = 0;
- char buf[VLA];
-
- initscr();
- noecho();
- nocbreak();
- nodelay(WIN95, TRUE);
- nonl();
- intrflush(WIN95, FALSE);
- curs_set(FALSE);
-
- if(FALSE == (has_colors())) {
- RESTORE_CURSOR();
- return EXIT_FAILURE;
- }
- start_color();
-
- for (x = 0; x < EIGHT; x++) {
- for (z = 0; z < EIGHT; z++) {
- init_pair((int16_t)((x * EIGHT) + z), x, z);
- }
- }
-
- pair_content(color_pair, &fg, &bg);
- getmaxyx(WIN95, old_y, old_x);
-
- while (1) {
- getmaxyx(WIN95, new_y, new_x);
- if (old_y != new_y || old_x != new_x) {
- old_y = new_y;
- old_x = new_x;
- werase(WIN95);
- wrefresh(WIN95);
- }
- if (NULL != (fgets(buf, VLA, stdin))) {
- unuglify(buf);
- }
- if (1 == call_it_quits) {
- break;
- }
- }
-
- RESTORE_CURSOR();
- fprintf(stderr, "\n%s\n", "See you later");
-
- return EXIT_SUCCESS;
-}
-
-/*
- * The signal handler is based on
- * https://www.gnu.org/software/libc/manual/html_node/Advanced-Signal-Handling.html#Advanced-Signal-Handling
-*/
-void init_da_handler(void) {
- struct sigaction setup_action;
- memset(&setup_action, 0, sizeof(struct sigaction));
-
- setup_action.sa_handler = &sighandler;
- setup_action.sa_flags = 0;
-
- if (-1 == sigaction(SIGINT, &setup_action, NULL)) {
- fprintf(stderr, "%s\n", "sigaction() failed");
- exit(EXIT_FAILURE);
- }
-}
-
-/* !!! WARNING !!! */
-void sighandler(int num) {
-/* ASYNC CODE ONLY */
- (void)num;
- call_it_quits = 1;
-}
-
-void unuglify(char *str1) {
- uint8_t iclr = 0;
- char *ptr = str1, cclr[1];
-
- wmove(WIN95, 0, 0);
- wclrtoeol(WIN95);
-
- for (; *ptr; ptr++) {
- if (0 != (iscntrl((unsigned char) *ptr))) {
- continue;
- }
- if ('^' == *ptr) {
- cclr[0] = *(++ptr);
- switch((toupper((unsigned char) *ptr))) {
- case 'B':
- iclr = COLOR_BLUE;
- break;
- case 'M':
- iclr = COLOR_MAGENTA;
- break;
- case 'Y':
- iclr = COLOR_YELLOW;
- break;
- default:
- waddch(WIN95, (chtype)cclr[0]);
- break;
- }
- wattrset(WIN95,
- COLOR_PAIR((iclr % EIGHT) * EIGHT) | A_BOLD);
- } else {
- waddch(WIN95, (chtype)*ptr);
- }
- }
- wrefresh(WIN95);
-}
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include "config.h" /* Auto-generated */
-
-#if WITH_NET == 1
-
-#if defined(__linux__)
-#include <netdb.h>
-/* #include <sys/types.h> */
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-#include <linux/if_link.h>
-#include <netpacket/packet.h>
-#include <net/if.h>
-#include <linux/sockios.h>
-#include <linux/ethtool.h>
-#include <linux/if.h>
-
-#if WITH_PCI == 1
-#include <pci/pci.h>
-#endif /* WITH_PCI */
-
-#endif /* __linux__ */
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
-#include <netdb.h>
-/* #include <sys/types.h> */
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <ifaddrs.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#endif /* __FreeBSD__ || __OpenBSD__ */
-
-#endif /* WITH_NET */
-
-#include "include/headers.h"
-#include "prototypes/net.h"
-
-#if defined(__FreeBSD__)
-#include "include/freebzd.h"
-#endif /* __FreeBSD__ */
-
-#if defined(__OpenBSD__)
-#include "include/openbzd.h"
-#endif /* __OpenBSD__ */
-
-/* Thanks to http://www.matisse.net/bitcalc/?source=print
- * and `man netdevice' */
-void
-get_net(char *str1, char *str2, uint8_t num) {
-#if WITH_NET == 1
-
-#if defined(__linux)
- struct rtnl_link_stats *stats = NULL;
- struct sockaddr_ll *mac = NULL;
-#else
- struct if_data *stats = NULL;
- struct sockaddr_dl *mac = NULL;
-#endif /* __linux__ */
-
- struct ifaddrs *ifaddr = NULL, *ifa = NULL;
- static uintmax_t prev_recv = 0, prev_sent = 0;
- uintmax_t cur_recv = 0, cur_sent = 0;
- unsigned char *umac = NULL;
- void *temp_void = NULL;
- char temp[VLA];
-
- if (-1 == getifaddrs(&ifaddr)) {
- FUNC_FAILED("getifaddrs()");
- }
- FILL_STR_ARR(1, str1, "Null");
-
- for (ifa = ifaddr; NULL != ifa; ifa = ifa->ifa_next) {
- if ((IFF_UP | IFF_BROADCAST) != (ifa->ifa_flags & (
- IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT |
- IFF_LOOPBACK | IFF_NOARP))) {
- continue;
- }
- if (NULL == ifa->ifa_addr) {
- continue;
- }
- if (3 == num || 5 == num || 6 == num) { /* ip | netmask | broadcast */
- if (ifa->ifa_addr->sa_family == AF_INET) {
- if (STREQ(str2, ifa->ifa_name)) {
- switch(num) {
- case 3:
- temp_void = ifa->ifa_addr;
- break;
- case 5:
- temp_void = ifa->ifa_netmask;
- break;
- case 6:
- temp_void = ifa->ifa_broadaddr;
- break;
- }
- inet_ntop(AF_INET, &(((struct sockaddr_in *)temp_void)->sin_addr),
- temp, INET_ADDRSTRLEN);
- FILL_STR_ARR(1, str1, temp);
- break;
- }
- }
- } else if (ifa->ifa_addr->sa_family == NETFAM &&
- NULL != ifa->ifa_data) {
- if (STREQ(str2, ifa->ifa_name)) {
-
-#if defined(__linux__)
- stats = ifa->ifa_data;
-#else
- stats = (struct if_data *)ifa->ifa_data;
-#endif /* __linux__ */
-
- if (2 == num) { /* upload and download speeds */
- cur_recv = (uintmax_t)stats->RECVBYTS - prev_recv;
- cur_sent = (uintmax_t)stats->SENTBYTS - prev_sent;
-
- FILL_ARR(str1, "Down " FMT_UINT " KB, Up " FMT_UINT " KB",
- (cur_recv / KB), (cur_sent / KB));
-
- prev_recv = cur_recv;
- prev_sent = cur_sent;
- } else if (1 == num) { /* consumed internet so far */
-
- FILL_ARR(str1, "Down " FMT_UINT " MB, Up " FMT_UINT " MB",
- ((uintmax_t)stats->RECVBYTS / MB),
- ((uintmax_t)stats->SENTBYTS / MB));
-
-#if defined(__linux__)
- } else if (4 == num) { /* mac address */
-
- temp_void = ifa->ifa_addr;
- mac = (struct sockaddr_ll *)temp_void;
- /*
- 6 == ether
- 20 == infiniband
- */
- if (6 != mac->sll_halen) {
- break;
- }
- FILL_ARR(str1, "%02x:%02x:%02x:%02x:%02x:%02x",
- mac->sll_addr[0], mac->sll_addr[1],
- mac->sll_addr[2], mac->sll_addr[3],
- mac->sll_addr[4], mac->sll_addr[5]);
- } else if (7 == num || 8 == num || 9 == num ||
- 10 == num) { /* link speed | driver | version | firmware */
-
- get_nic_info2(str1, str2, (uint8_t)(num - 6));
- }
-#else
- } else if (4 == num) { /* mac address */
- temp_void = ifa->ifa_addr;
- mac = (struct sockaddr_dl *)temp_void;
- /*
- 6 == ether
- 20 == infiniband
- */
- if (6 != mac->sdl_alen) {
- break;
- }
- umac = (unsigned char *)LLADDR(mac);
- FILL_ARR(str1, "%02x:%02x:%02x:%02x:%02x:%02x",
- *umac, *(umac + 1), *(umac + 2),
- *(umac + 3), *(umac + 4), *(umac + 5));
- } else if (7 == num) { /* gateway */
- get_nic_info(str1, str2);
- }
-#endif /* __linux__ */
- break;
- }
- }
- }
- if (NULL != ifaddr) {
- freeifaddrs(ifaddr);
- }
-
-#else
- (void)str1;
- (void)str2;
- (void)num;
- RECOMPILE_WITH("net");
-#endif /* WITH_NET */
-}
-
-
-void
-get_ip_lookup(char *str1, char *str2) {
-#if WITH_NET == 1
-
- struct addrinfo *rp = NULL, *result = NULL, hints;
- void *temp_void = NULL;
- char temp[VLA];
-
- memset(&hints, 0, sizeof(struct addrinfo));
-
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_flags = 0;
- hints.ai_protocol = 0; /* udp | tcp */
-
- if (0 != (getaddrinfo(str2, NULL, &hints, &result))) {
- FUNC_FAILED("getaddrinfo()");
- }
-
- for (rp = result; NULL != rp; rp = rp->ai_next) {
- if (NULL == rp->ai_addr) {
- continue;
- }
- /* check ipv4 again, despite the "hints" */
- if (rp->ai_family == AF_INET) {
- temp_void = rp->ai_addr;
-
- inet_ntop(AF_INET, &(((struct sockaddr_in *)temp_void)->sin_addr),
- temp, INET_ADDRSTRLEN);
- FILL_STR_ARR(1, str1, temp);
-
- break;
- }
- }
- if ('\0' == str1[0]) {
- FILL_STR_ARR(1, str1, "Null");
- }
- if (NULL != result) {
- freeaddrinfo(result);
- }
-
-#else
- (void)str1;
- (void)str2;
- RECOMPILE_WITH("net");
-#endif /* WITH_NET */
-}
-
-
-/* It's so nice that the FreeBSD kernel
- does all the heavy lifting for us.
- In Linux you get only the hex numbers.
-
-sysctl -a | grep 'dev.re.0'
-
-dev.re.0.wake: 0
-dev.re.0.int_rx_mod: 65
-dev.re.0.stats: -1
-dev.re.0.%parent: pci2
-dev.re.0.%pnpinfo: vendor=0x10ec device=0x8168 subvendor=0x1043 subdevice=0x8432 class=0x020000
-dev.re.0.%location: pci0:2:0:0 handle=\_SB_.PCI0.PCE4.RLAN
-dev.re.0.%driver: re
-dev.re.0.%desc: RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet */
-
-
-#if defined(__linux__)
-/* Not using exit_with_err to freeifaddrs */
-void
-get_nic_info2(char *str1, char *str2, uint8_t num) {
-#if WITH_NET == 1
-
- struct ethtool_cmd ecmd;
- struct ethtool_drvinfo drvinfo;
- struct ifreq ifr;
- int sock = 0;
-
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- if (-1 == sock) {
- return;
- }
-
- memset(&ecmd, 0, sizeof(struct ethtool_cmd));
- memset(&drvinfo, 0, sizeof(struct ethtool_drvinfo));
- memset(&ifr, 0, sizeof(struct ifreq));
-
- switch(num) {
- case 1:
- ecmd.cmd = ETHTOOL_GSET;
- ifr.ifr_data = (char *)&ecmd;
- break;
- case 2:
- case 3:
- case 4:
- drvinfo.cmd = ETHTOOL_GDRVINFO;
- ifr.ifr_data = (char *)&drvinfo;
- break;
- }
- snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", str2);
-
- if (0 != (ioctl(sock, SIOCETHTOOL, &ifr))) {
- return;
- }
-
- /* The `ethtool_cmd_speed' negotiation concept
- * is great, but the `SPEED_X' macros are not.
- * They are constants representing the link speed
- * from 10 Mbps up to 100 Gbps, but as we know,
- * the wifi/wireless "things" suffer from various
- * degradations, thus those macros are only reliable
- * to detect wired NIC that doesn't tend to change
- * it's link speed from various real-life factors.
- */
- switch(num) {
- case 1:
- FILL_ARR(str1, "%d%s", ecmd.speed, "Mbps");
- break;
- case 2:
- FILL_STR_ARR(1, str1, drvinfo.driver);
- break;
- case 3:
- FILL_STR_ARR(1, str1, drvinfo.version);
- break;
- case 4:
- FILL_STR_ARR(1, str1, drvinfo.fw_version);
- break;
- }
-
-#else
- (void)str1;
- (void)str2;
- (void)num;
- RECOMPILE_WITH("net");
-#endif /* WITH_NET */
-}
-
-
-/*
- Quick spot the bug game.
- code begin:
- struct pci_access *pacc= NULL;
- pacc = pci_alloc();
- pci_init(pacc);
- pci_cleanup(pacc);
- code end;
- Spotted the bug - no ? Well,
- GCC -O2 hangs on pci_init,
- while -O0 executes flawlessly.
- Disclaimer: the code is perfectly valid.
-*/
-void
-get_nic_info(char *str1, char *str2) {
-#if WITH_PCI == 1 && WITH_NET == 1
-
- uintmax_t vendor = 0, model = 0;
- char temp[VLA];
- struct pci_access *pacc = NULL;
- struct pci_dev *dev = NULL;
- FILE *fp;
-
- FILL_STR_ARR(1, str1, "Null");
- NIC_VEND(temp, str2);
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, temp, SCAN_UINTX, &vendor); /* hex */
-#pragma GCC diagnostic pop
-
- NIC_MODEL(temp, str2);
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
- OPEN_X(fp, temp, SCAN_UINTX, &model); /* hex */
-#pragma GCC diagnostic pop
-
- pacc = pci_alloc();
- if (NULL == pacc) {
- goto error;
- }
-
- pci_init(pacc);
- if (NULL == pacc) {
- goto error;
- }
- pci_scan_bus(pacc);
-
- for (dev = pacc->devices; NULL != dev; dev = dev->next) {
- pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS);
-
- if ((uintmax_t)vendor == (uintmax_t)dev->vendor_id &&
- (uintmax_t)model == (uintmax_t)dev->device_id) {
-
- pci_lookup_name(pacc, temp, VLA,
- PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
- (uintmax_t)vendor, (uintmax_t)model);
-
- FILL_STR_ARR(1, str1, temp);
- break;
- }
- }
-
-error:
- if (NULL != pacc) {
- pci_cleanup(pacc);
- }
- return;
-
-#else
- (void)str1;
- (void)str2;
- RECOMPILE_WITH("pci");
-#endif /* WITH_PCI && WITH_NET */
-}
-
-#endif /* __linux__ */
-
-
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
-#define ROUNDUP(x) ((x) > 0 ? \
- (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
-
-/* Based on:
- http://fossies.org/linux/misc/old/mrt-2.2.2a-src.tar.gz/mrt-2.2.2a/src/lib/kernel/bsd.c
- https://svn.nmap.org/nmap/libdnet-stripped/src/route-bsd.c
-*/
-void
-get_nic_info(char *str1, char *str2) {
-#if WITH_NET == 1
-
- (void)str2;
-
- struct rt_msghdr *rtm = NULL;
- struct sockaddr *sa = NULL, *addrs[RTAX_MAX];
- char *buf = NULL, *next = NULL, *lim = NULL, temp[VLA];
- uint8_t x = 0;
- size_t needed = 0;
- void *temp_void = NULL;
-
- /* No, it's not Men In Black acronym */
- int mib[] = { CTL_NET, PF_ROUTE, 0, 0, NET_RT_DUMP, 0 };
- if (0 != (sysctl(mib, 6, NULL, &needed, NULL, 0))) {
- return;
- }
-
- buf = (char *)malloc(needed);
- if (NULL == buf) {
- return;
- }
- if (0 != (sysctl(mib, 6, buf, &needed, NULL, 0))) {
- goto error;
- }
-
- lim = buf + needed;
- for (next = buf; next < lim; next += rtm->rtm_msglen) {
- rtm = (struct rt_msghdr *)(void *)next;
- sa = (struct sockaddr *)(rtm + 1);
- if (NULL == sa || NULL == rtm) {
- continue;
- }
- if (sa->sa_family == AF_INET) {
- for (x = 0; x < RTAX_MAX; x++) {
- if (rtm->rtm_addrs & (1 << x)) {
- addrs[x] = sa;
- sa = (struct sockaddr *)((char *)sa + ROUNDUP(sa->sa_len));
- } else {
- addrs[x] = NULL;
- }
- }
- if (((rtm->rtm_addrs & (RTA_DST|RTA_GATEWAY)) == (RTA_DST|RTA_GATEWAY))
- && addrs[RTAX_DST]->sa_family == AF_INET
- && addrs[RTAX_GATEWAY]->sa_family == AF_INET) {
-
- temp_void = addrs[RTAX_GATEWAY];
- inet_ntop(AF_INET, &(((struct sockaddr_in *)temp_void)->sin_addr),
- temp, INET_ADDRSTRLEN);
- FILL_STR_ARR(1, str1, temp);
- break;
- }
- }
- }
-
-error:
- if (NULL != buf) {
- free(buf);
- }
- return;
-
-#else
- (void)str1;
- (void)str2;
- RECOMPILE_WITH("net");
-#endif /* WITH_NET */
-}
-#endif /* __FreeBSD__ || __OpenBSD__ */
+++ /dev/null
-/*
- 09/08/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include "config.h" /* Auto-generated */
-
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/swap.h>
-#include <sys/disk.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/sensors.h>
-#include <machine/apmvar.h>
-
-#include "include/headers.h"
-#include "include/openbzd.h"
-
-/*
- Used resources:
- $OpenBSD: uvm_meter.c,v 1.36 2015/03/14 03:38:53 jsg Exp $
- $OpenBSD: machine.c,v 1.63 2007/11/01 19:19:48 otto Exp $
-*/
-
-void
-get_ram(char *str1, uint8_t num) {
- uintmax_t total = 0, freeram = 0, pz = 0;
-
- pz = (uintmax_t)sysconf(_SC_PAGESIZE);
- total = ((uintmax_t)sysconf(_SC_PHYS_PAGES) * pz) / MB;
- freeram = ((uintmax_t)sysconf(_SC_AVPHYS_PAGES) * pz) / MB;
-
- switch(num) {
- case 1:
- case 2:
- FILL_ARR(str1, FMT_UINT "%s",
- ((1 == num) ? total: freeram), "MB");
- break;
- case 3:
- FILL_ARR(str1, FMT_UINT "%s", (total - freeram), "MB");
- break;
- case 5:
- FILL_UINT_ARR(str1, ((total - freeram) * 100) / total);
- break;
- }
-}
-
-
-void
-match_feature(char *str1, uint8_t sens_type, uint8_t sens_num) {
- int mib[] = { CTL_HW, HW_SENSORS, 0, sens_type, 0 };
- struct sensordev dev;
- struct sensor sens;
- uint_fast16_t rpm[MAX_FANS+1];
- uint8_t x = 0, y = 0, z = 0;
- uintmax_t temp = 0;
- char buffer[VLA];
- char *all = buffer;
- bool found_fans = false;
-
- memset(rpm, 0, sizeof(rpm));
- memset(&dev, 0, sizeof(struct sensordev));
- memset(&sens, 0, sizeof(struct sensor));
-
- size_t dev_len = sizeof(dev), sens_len = sizeof(sens);
- SYSCTLVAL(mib, 3, &dev, &dev_len);
-
- for (mib[4] = 0; mib[4] < dev.maxnumt[sens_type]; mib[4]++) {
- if (0 != (sysctl(mib, 5, &sens, &sens_len, NULL, 0))) {
- break;
- }
- if (0 != sens_len &&
- !(sens.flags & (SENSOR_FINVALID | SENSOR_FUNKNOWN))) {
-
- switch(sens_type) {
- case SENSOR_VOLTS_DC:
- GLUE2(all, "%.2f ", ((float)sens.value / 1000000.0f));
- break;
-
- case SENSOR_TEMP:
- {
- if (x == sens_num) {
- temp = (uintmax_t)sens.value;
- }
- x++;
- }
- break;
-
- case SENSOR_FANRPM:
- {
- if (MAX_FANS != z) {
- rpm[z++] = (uint_fast16_t)sens.value;
- }
- found_fans = true;
- }
- break;
-
- default:
- continue;
- }
- }
- }
-
- if (SENSOR_VOLTS_DC == sens_type && '\0' != buffer[0]) {
- size_t len = strlen(buffer);
- buffer[len-1] = '\0';
-
- FILL_STR_ARR(1, str1, buffer);
- return;
- }
- if (SENSOR_TEMP == sens_type) {
- if (999999999 < temp) { /* > 99C */
- FILL_UINT_ARR(str1, temp / 100000000);
- } else {
- FILL_UINT_ARR(str1, ((99999999 < temp) ?
- temp / 10000000 : temp / 1000000)); /* > 9C || < 9C */
- }
- return;
- }
- if (found_fans) {
- check_fan_vals(str1, rpm, z);
- }
-}
-
-
-void
-get_voltage(char *str1) {
- match_feature(str1, SENSOR_VOLTS_DC, 0);
-}
-
-
-void
-get_mobo_temp(char *str1) {
- match_feature(str1, SENSOR_TEMP, 1);
-}
-
-
-void
-get_fans(char *str1) {
- match_feature(str1, SENSOR_FANRPM, 0);
-}
-
-
-void
-get_cpu_temp(char *str1) {
- match_feature(str1, SENSOR_TEMP, 0);
-}
-
-
-void
-get_mobo(char *str1) {
- int mib[] = { CTL_HW, HW_VENDOR };
- int mib2[] = { CTL_HW, HW_PRODUCT };
- char vendor[100], model[100];
- size_t len = sizeof(vendor);
-
- SYSCTLVAL(mib, 2, &vendor, &len);
- SYSCTLVAL(mib2, 2, &model, &len);
-
- split_n_index(vendor);
- split_n_index(model);
-
- FILL_STR_ARR(2, str1, vendor, model);
-}
-
-
-/*
- * Entirely based on:
- * $OpenBSD: apmd.c,v 1.49 2007/11/24 14:58:44 deraadt Exp $
- * The source mentioned different values when
- * using Crapple machine that is charging the battery
-*/
-void
-get_battery(char *str1) {
- struct apm_power_info bstate;
- int fd = 0;
- uintmax_t dummy = 0;
-
- FILL_STR_ARR(1, str1, "Null");
- memset(&bstate, 0, sizeof(struct apm_power_info));
-
- if (0 != (fd = open("/dev/apm", O_RDONLY))) {
- return;
- }
- if (0 != (ioctl(fd, APM_IOC_GETPOWER, &bstate))) {
- CLOSE_FD(fd);
- return;
- }
- CLOSE_FD(fd);
-
- if (APM_BATT_UNKNOWN == bstate.battery_state ||
- APM_BATTERY_ABSENT == bstate.battery_state) {
- return;
- }
-
- dummy = (uintmax_t)bstate.battery_life;
- FILL_UINT_ARR(str1, (101 < dummy ? 0 : dummy));
-}
-
-
-/*
- * Based on:
- * $OpenBSD: swap.c,v 1.27 2015/08/20 22:32:42 deraadt Exp $
-*/
-void
-get_swapp(char *str1, uint8_t num) {
- struct swapent *dev = NULL;
- int count = 0, stats = 0, x = 0;
- uintmax_t total = 0, used = 0;
-
- FILL_STR_ARR(1, str1, "0 MB");
- if (-1 == (count = swapctl(SWAP_NSWAP, 0, 0))) {
- return;
- }
-
- dev = (struct swapent *)malloc(
- (unsigned long)count * sizeof(struct swapent));
- if (NULL == dev) {
- return;
- }
-
- stats = swapctl(SWAP_STATS, dev, count);
- if (-1 == stats || stats != count) {
- goto error;
- }
-
- for (x = 0; x < count; x++) {
- total += (uintmax_t)dev->se_nblks;
- used += (uintmax_t)dev->se_inuse;
- }
-
- switch(num) {
- case 1:
- FILL_ARR(str1, FMT_UINT" %s", BYTES_TO_MB(total), "MB");
- break;
- case 2:
- FILL_ARR(str1, FMT_UINT" %s",
- BYTES_TO_MB((total - used)), "MB");
- break;
- case 3:
- FILL_ARR(str1, FMT_UINT" %s", BYTES_TO_MB(used), "MB");
- break;
- case 4:
- {
- if (0 != total) {
- FILL_ARR(str1, FMT_UINT"%%", (used * 100) / total);
- } else {
- FILL_STR_ARR(1, str1, "0 %");
- }
- }
- break;
- }
-
-error:
- if (NULL != dev) {
- free(dev);
- }
- return;
-}
-
-
-void
-get_statio(char *str1, char *str2) {
- struct diskstats *ds = NULL;
- int mib[] = { CTL_HW, HW_DISKSTATS };
- uint_least16_t x = 0;
- size_t len = 0, drivez = 0;
-
- FILL_STR_ARR(1, str1, "Null");
- SYSCTLVAL(mib, 2, NULL, &len);
-
- if (0 == (drivez = (len / sizeof(*ds)))) {
- return;
- }
-
- ds = (struct diskstats *)malloc(drivez * sizeof(char *));
- if (NULL == ds) {
- return;
- }
- if (0 != (sysctl(mib, 2, ds, &len, NULL, 0))) {
- goto error;
- }
-
- for (x = 0; x < drivez; x++) {
- if (STREQ(str2, ds[x].ds_name)) {
- FILL_ARR(str1, "Read " FMT_UINT " MB, Written " FMT_UINT " MB",
- (uintmax_t)ds[x].ds_rbytes / MB,
- (uintmax_t)ds[x].ds_wbytes / MB);
- break;
- }
- }
-
-error:
- if (NULL != ds) {
- free(ds);
- }
- return;
-}
+++ /dev/null
-/*
- 08/08/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include <argp.h>
-#include <limits.h>
-
-#include "config.h" /* Auto-generated */
-#include "include/headers.h"
-#include "prototypes/cpu.h"
-#include "prototypes/sound.h"
-#include "prototypes/net.h"
-#include "prototypes/options.h"
-
-/* Because we ran out of a-z A-Z options,
- * only long ones will be supported from now on.
- * The enumerated argp_option keys below will be used as
- * case labels by the parse_opt switch */
-enum {
- EXZTRA = CHAR_MAX + 1,
- BULLSHIT
-};
-const char *argp_program_version = PACKAGE_STRING;
-const char *argp_program_bug_address = "https://gitlab.com/void0/pinky-bar ";
-static const char doc[] = "Statusbar program for anything (Window Manager, terminal multiplexer, etc..)";
-static const struct argp_option options[] = {
- { .doc = "Available options:" },
- { .name = "mpd", .key = 'M', .doc = "The song filename." },
- { .name = "mpdartist", .key = 'x', .doc = "The song artist(s) name(s)." },
- { .name = "mpdtitle", .key = 'X', .doc = "The song title." },
- { .name = "mpdalbum", .key = 'y', .doc = "The song album name." },
- { .name = "mpddate", .key = 'Y', .doc = "The song date." },
- { .name = "cpu", .key = 'c', .doc = "The current cpu load (summed up all cores/threads)." },
- { .name = "coresload", .key = 'L', .doc = "Show the load regarding each individual cpu core/thread." },
- { .name = "cpuspeed", .key = 'C', .doc = "The current cpu temperature." },
- { .name = "cpuinfo", .key = 'I', .doc = "Show your maximum cpu clock speed in MHz." },
- { .name = "cputemp", .key = 'T', .doc = "Detect your CPU vendor, stepping, family." },
- { .name = "ramperc", .key = 'r', .doc = "The used ram in percentage." },
- { .name = "ramtotal", .key = 'J', .doc = "The total ram." },
- { .name = "ramfree", .key = 'K', .doc = "The free ram." },
- { .name = "driveperc", .key = 's', .doc = "The used drive storage in percentage." },
- { .name = "drivetotal", .key = 'n', .doc = "The total drive storage." },
- { .name = "drivefree", .key = 'N', .doc = "The free drive storage." },
- { .name = "driveavail", .key = 'O', .doc = "The available drive storage." },
- { .name = "dvdstr", .key = 'z', .doc = "The vendor and model name of your cdrom/dvdrom." },
- { .name = "battery", .key = 'g', .doc = "The remaining battery charge." },
- { .name = "packages", .key = 'p', .doc = "The number of installed packages." },
- { .name = "kernsys", .key = 'P', .doc = "The kernel name." },
- { .name = "kernode", .key = 'q', .doc = "The network node hostname." },
- { .name = "kernrel", .key = 'Q', .doc = "The kernel release." },
- { .name = "kernver", .key = 'R', .doc = "The kernel version." },
- { .name = "kernarch", .key = 'u', .doc = "The machine architecture." },
- { .name = "kernel", .key = 'k', .doc = "Combined kernel name and version." },
- { .name = "uptime", .key = 'U', .doc = "The system uptime" },
- { .name = "loadavg", .key = 'w', .doc = "The system average load for past 1, 5 and 15 minutes" },
- { .name = "voltage", .key = 'v', .doc = "The system voltage" },
- { .name = "fans", .key = 'f', .doc = "All system fans and their speed in RPM." },
- { .name = "mobo", .key = 'm', .doc = "The motherboard vendor and model names." },
- { .name = "mobotemp", .key = 'd', .doc = "The motherboard temperature." },
- { .name = "volume", .key = 'V', .doc = "The volume." },
- { .name = "time", .key = 't', .doc = "The current time." },
- { .name = "ipaddr", .key = 'a', .arg = "eth0", .doc = "The local IP address." },
- { .name = "iface", .key = 'i', .arg = "eth0", .doc = "The consumed internet bandwidth so far." },
- { .name = "bandwidth", .key = 'b', .arg = "eth0", .doc = "The current download and upload speeds." },
- { .name = "ipmac", .key = 'A', .arg = "eth0", .doc = "The NIC mac address." },
- { .name = "ipmask", .key = 'B', .arg = "eth0", .doc = "The NIC subnet mask address." },
- { .name = "ipcast", .key = 'D', .arg = "eth0", .doc = "The NIC broadcast address." },
- { .name = "iplookup", .key = 'E', .arg = "site", .doc = "Mini website IP lookup." },
- { .name = "statio", .key = 'S', .arg = "sda", .doc = "Read and written MBs to the drive so far." },
-
-#if defined(HAVE_MPD_CLIENT_H)
- { .name = "mpdtrack", .key = 'W', .doc = "The song track name." },
-#endif /* HAVE_MPD_CLIENT_H */
-
-#if !defined(__OpenBSD__)
- { .name = "ramshared", .key = 'l', .doc = "The shared ram." },
- { .name = "rambuffer", .key = 'o', .doc = "The buffered ram." },
-#endif /* !__OpenBSD__ */
-
-
-#if defined(__OpenBSD__)
- { .name = "ramused", .key = 'l', .doc = "The used ram in MB." },
-#endif /* __OpenBSD__ */
-
-#if defined(__linux__)
- { .name = "nicfw", .key = 'j', .arg = "eth0", .doc = "The NIC firmware." },
- { .name = "drivemodel", .key = 'F', .arg = "sda", .doc = "The vendor name of your drive." },
- { .name = "nicdrv", .key = 'h', .arg = "eth0", .doc = "The NIC driver." },
- { .name = "nicver", .key = 'H', .arg = "eth0", .doc = "The NIC version." },
- { .name = "iplink", .key = 'e', .arg = "eth0", .doc = "The NIC link speed (useful for wireless/wifi)." },
- { .name = "nicinfo", .key = 'G', .arg = "eth0", .doc = "The NIC vendor and model." },
-#endif /* __linux__ */
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
- { .name = "swapused", .key = 'Z', .doc = "The used drive swap in MB." },
- { .name = "swaperc", .key = 'F', .doc = "The used drive swap in percentage." },
- { .name = "swaptotal", .key = 'h', .doc = "The total drive swap." },
- { .name = "swapavail", .key = 'H', .doc = "The available drive swap." },
- { .name = "nicgw", .key = 'j', .arg = "re0", .doc = "The NIC gateway address." },
-#endif /* __FreeBSD__ || __OpenBSD__ */
-
- { .doc = NULL }
-};
-struct arguments {
- char *all;
-};
-
-static error_t
-parse_opt(int key, char *arg, struct argp_state *state) {
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
- struct timespec tc = {0};
-#pragma GCC diagnostic pop
-
- struct arguments *arguments = state->input;
- switch(key) {
-
- NEW_MPD_LABEL('x', char song_artist[VLA], song_artist, 2);
-
- NEW_MPD_LABEL('X', char song_title[VLA], song_title, 3);
-
- NEW_MPD_LABEL('y', char song_album[VLA], song_album, 4);
-
- NEW_MPD_LABEL('Y', char song_date[VLA], song_date, 5);
-
- NEW_MPD_LABEL('M', char song[VLA], song, 6);
-
- NEW_CPU_LABEL('c', char cpu[VLA], cpu, FMT_CPU, CPU_STR);
-
- NEW_CPU_LABEL('L', char cores_load[VLA], cores_load, FMT_CORES, CPU_STR);
-
- NEW_LABEL('T', char cpu_temp[VLA], cpu_temp, FMT_TEMP);
-
- NEW_RAM_LABEL('J', char ram_total[VLA], ram_total, 1, FMT_RAM2, RAM_STR);
-
- NEW_RAM_LABEL('K', char ram_free[VLA], ram_free, 2, FMT_RAM2, RAM_STR);
-
- NEW_RAM_LABEL('r', char ram_perc[VLA], ram_perc, 5, FMT_RAM, RAM_STR);
-
- NEW_SSD_LABEL('n', char ssd_total[VLA], ssd_total, 1, FMT_SSD2, SSD_STR);
-
- NEW_SSD_LABEL('N', char ssd_free[VLA], ssd_free, 2, FMT_SSD2, SSD_STR);
-
- NEW_SSD_LABEL('O', char ssd_avail[VLA], ssd_avail, 3, FMT_SSD2, SSD_STR);
-
- NEW_SSD_LABEL('s', char ssd_perc[VLA], ssd_perc, 4, FMT_SSD, SSD_STR);
-
- NEW_LABEL('p', char packs[VLA], packs, FMT_PKGS, PKG_STR);
-
- NEW_KERNEL_LABEL('P', char kernel_sys[VLA], kernel_sys, 1, FMT_KERN);
-
- NEW_KERNEL_LABEL('q', char kernel_node[VLA], kernel_node, 2, FMT_KERN);
-
- NEW_KERNEL_LABEL('Q', char kernel_rel[VLA], kernel_rel, 3, FMT_KERN);
-
- NEW_KERNEL_LABEL('R', char kernel_ver[VLA], kernel_ver, 4, FMT_KERN);
-
- NEW_KERNEL_LABEL('u', char kernel_arch[VLA], kernel_arch, 5, FMT_KERN);
-
- NEW_KERNEL_LABEL('k', char kernel[VLA], kernel, 6, FMT_KERN);
-
- NEW_LABEL('U', char uptime[VLA], uptime, FMT_UP, UP_STR);
-
- NEW_LABEL('w', char loadavg[VLA], loadavg, FMT_LOAD, LOAD_STR);
-
- NEW_LABEL('v', char voltage[VLA], voltage, FMT_VOLT, VOLT_STR);
-
- NEW_LABEL('m', char mobo[VLA], mobo, FMT_MOBO, MOBO_STR);
-
- NEW_LABEL('d', char mobo_temp[VLA], mobo_temp, FMT_TEMP);
-
- NEW_LABEL('f', char fans[VLA], fans, FMT_FANS, FANS_STR);
-
- NEW_LABEL('t', char taim[VLA], taim, FMT_TIME" ", TIME_STR);
-
- NEW_NET_LABEL('b', char net[VLA], net, 1, FMT_NET, NET_STR);
-
- NEW_NET_LABEL('i', char net_speed[VLA], net_speed, 2, FMT_NET, SPEED_STR);
-
- NEW_NET_LABEL('a', char net_addr[VLA], net_addr, 3, FMT_KERN);
-
- NEW_NET_LABEL('A', char mac[VLA], mac, 4, FMT_KERN);
-
- NEW_NET_LABEL('B', char mask[VLA], mask, 5, FMT_KERN);
-
- NEW_NET_LABEL('D', char net_cast[VLA], net_cast, 6, FMT_KERN);
-
- NEW_ARG_LABEL('E', char ip_lookup[VLA], ip_lookup, FMT_KERN);
-
- NEW_RAM_LABEL('l', char ram_shared[VLA], ram_shared, 3, FMT_RAM2, RAM_STR);
-
- NEW_LABEL('g', char battery[VLA], battery, FMT_BATT, BATT_STR);
-
- NEW_ARG_LABEL('S', char statio[VLA], statio, FMT_STATIO, STATIO_STR);
-
-#if defined(HAVE_MPD_CLIENT_H)
- NEW_MPD_LABEL('W', char song_track[VLA], song_track, 1);
-#endif /* HAVE_MPD_CLIENT_H */
-
-
-#if defined(HAVE_CDIO_CDIO_H) || defined(__linux__)
- NEW_LABEL('z', char dvd[VLA], dvd, FMT_KERN);
-#endif /* HAVE_CDIO_CDIO_H || __linux__ */
-
-
-#if !defined(__OpenBSD__)
- NEW_RAM_LABEL('o', char ram_buffer[VLA], ram_buffer, 4, FMT_RAM2, RAM_STR);
-#endif /* !__OpenBSD__ */
-
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
- NEW_SWAPP_LABEL('h', char swapp_total[VLA], swapp_total, 1, FMT_SSD2, SSD_STR);
-
- NEW_SWAPP_LABEL('H', char swapp_avail[VLA], swapp_avail, 2, FMT_SSD2, SSD_STR);
-
- NEW_SWAPP_LABEL('Z', char swapp_used[VLA], swapp_used, 3, FMT_SSD2, SSD_STR);
-
- NEW_SWAPP_LABEL('F', char swapp_perc[VLA], swapp_perc, 4, FMT_SSD2, SSD_STR);
-
- NEW_NET_LABEL('j', char nic_info[VLA], nic_info, 7, FMT_KERN);
-#endif /* __FreeBSD__ || __OpenBSD__ */
-
-
-#if defined(__linux__)
- NEW_NET_LABEL('j', char nic_info[VLA], nic_info, 10, FMT_KERN);
-
- NEW_ARG_LABEL('F', char ssd_model[VLA], ssd_model, FMT_KERN);
-
- NEW_NET_LABEL('h', char nic_drv[VLA], nic_drv, 8, FMT_KERN);
-
- NEW_NET_LABEL('H', char nic_ver[VLA], nic_ver, 9, FMT_KERN);
-
- NEW_ARG_LABEL('G', char nic_info[VLA], nic_info, FMT_KERN);
-
- NEW_NET_LABEL('e', char link_speed[VLA], link_speed, 7, FMT_KERN);
-#endif /* __linux__ */
-
-
- case 'V':
-#if defined(HAVE_ALSA_ASOUNDLIB_H) || defined(HAVE_SYS_SOUNDCARD_H) || \
- defined(HAVE_SOUNDCARD_H)
- {
- char volume[VLA];
- GET_N_FMT(volume, arguments->all, FMT_VOL, VOL_STR, volume);
- }
- break;
-#else
- FPRINTF("%s\n", "recompile the program --with-alsa or --with-oss");
- return ARGP_KEY_ERROR;
-#endif /* HAVE_ALSA_ASOUNDLIB_H || HAVE_SYS_SOUNDCARD_H || HAVE_SOUNDCARD_H */
-
- case 'C':
-#if defined(__i386__) || defined(__i686__) || defined(__x86_64__)
- {
- char cpu_clock_speed[VLA];
- GET_N_FMT(cpu_clock_speed, arguments->all, FMT_CPUSPEED, cpu_clock_speed);
- }
- break;
-#else
- FPRINTF("%s\n", "This option is not supported "
- "by your CPU architecture");
- return ARGP_KEY_ERROR;
-#endif /* __i386__ || __i686__ || __x86_64__ */
-
- case 'I':
-#if defined(__i386__) || defined(__i686__) || defined(__x86_64__)
- {
- char cpu_info[VLA];
- GET_N_FMT(cpu_info, arguments->all, FMT_CPUSPEED, cpu_info);
- }
- break;
-#else
- FPRINTF("%s\n", "This option is not supported "
- "by your CPU architecture");
- return ARGP_KEY_ERROR;
-#endif /* __i386__ || __i686__ || __x86_64__ */
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return EXIT_SUCCESS;
-}
-
-
-void
-parse_opts(int argc, char *argv[], char *combined) {
- struct arguments arguments;
- arguments.all = combined;
-
- static const struct argp arg_parser = {
- .parser = parse_opt,
- .options = options,
- .doc = doc
- };
- argp_parse(&arg_parser, argc, argv, ARGP_IN_ORDER, NULL, &arguments);
-}
+++ /dev/null
-# source - https://en.wikipedia.org/wiki/CPUID
-# used it to port it to pinky-bar
-
-.section .data
-
-s0 : .asciz "Processor Brand String: %.48s\n"
-err : .asciz "Feature unsupported.\n"
-
-.section .text
-
-.global main
-.type main,@function
-.align 32
-main:
- pushq %rbp
- movq %rsp, %rbp
- subq $48, %rsp
- pushq %rbx
-
- movl $0x80000000, %eax
- cpuid
-
- cmpl $0x80000004, %eax
- jl error
-
- movl $0x80000002, %esi
- movq %rsp, %rdi
-
-.align 16
-get_brand:
- movl %esi, %eax
- cpuid
-
- movl %eax, (%rdi)
- movl %ebx, 4(%rdi)
- movl %ecx, 8(%rdi)
- movl %edx, 12(%rdi)
-
- addl $1, %esi
- addq $16, %rdi
- cmpl $0x80000004, %esi
- jle get_brand
-
-print_brand:
- movq $s0, %rdi
- movq %rsp, %rsi
- xorb %al, %al
- call printf
-
- jmp end
-
-.align 16
-error:
- movq $err, %rdi
- xorb %al, %al
- call printf
-
-.align 16
-end:
- popq %rbx
- movq %rbp, %rsp
- popq %rbp
- xorl %eax, %eax
- ret
+++ /dev/null
-# source - https://en.wikipedia.org/wiki/CPUID
-# used it to port it to pinky-bar
-
-.section .data
-
-info : .ascii "L2 Cache Size : %u KB\nLine size : %u bytes\n"
-.asciz "Associativity : %02xh\n"
-err : .asciz "Feature unsupported.\n"
-
-.section .text
-
-.global main
-.type main,@function
-.align 32
-main:
- pushq %rbp
- movq %rsp, %rbp
- pushq %rbx
-
- movl $0x80000000, %eax
- cpuid
-
- cmpl $0x80000006, %eax
- jl error
-
- movl $0x80000006, %eax
- cpuid
-
- movl %ecx, %eax
-
- movl %eax, %edx
- andl $0xff, %edx
-
- movl %eax, %ecx
- shrl $12, %ecx
- andl $0xf, %ecx
-
- movl %eax, %esi
- shrl $16, %esi
- andl $0xffff,%esi
-
- movq $info, %rdi
- xorb %al, %al
- call printf
-
- jmp end
-
-.align 16
-error:
- movq $err, %rdi
- xorb %al, %al
- call printf
-
-.align 16
-end:
- popq %rbx
- movq %rbp, %rsp
- popq %rbp
- xorl %eax, %eax
- ret
+++ /dev/null
-/* "borrowed" from the Hacked Team */
-
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/statvfs.h>
-#include <sys/utsname.h>
-
-struct device_info {
- struct {
- char vendor[128];
- char model[128];
- char cpu[128];
- unsigned char ncpu;
- } hw;
- struct {
- unsigned int memt;
- unsigned int memf;
- unsigned int diskt;
- unsigned int diskf;
- } stat;
- struct {
- char ac[16];
- unsigned char battery;
- } power;
- struct {
- char ver[128];
- char arch[16];
- char lang[16];
- char tzname[8];
- char tzoff[8];
- } os;
- struct {
- char name[16];
- unsigned int uid;
- unsigned int gid;
- char gecos[64];
- char home[64];
- } user;
- struct {
- char list[1024];
- } mount;
-};
-
-int main(void);
-void device_hw(struct device_info *di);
-void device_stat(struct device_info *di);
-void device_power(struct device_info *di);
-void device_os(struct device_info *di);
-void device_user(struct device_info *di);
-void device_mount(struct device_info *di);
-
-int main(void)
-{
- struct device_info di;
-
- memset(&di, 0x00, sizeof(di));
- device_hw(&di);
- device_stat(&di);
- device_power(&di);
- device_os(&di);
- device_user(&di);
- device_mount(&di);
-
- printf("Device: %s %s\n", di.hw.vendor, di.hw.model);
- printf("Processor: %u x %s\n", di.hw.ncpu, di.hw.cpu);
- printf("Memory: %uMB (%u%% used)\n", di.stat.memt, 100 - di.stat.memf * 100 / di.stat.memt);
- printf("Disk: %uGB (%u%% used)\n", di.stat.diskt, 100 - di.stat.diskf * 100 / di.stat.diskt);
- printf("Power: AC %s - battery %%\n", di.power.ac);
- printf("\n");
- printf("OS Version: Linux %s (%s)\n", di.os.ver, di.os.arch);
- printf("Locale settings: %s - %s (UTC %s)\n", di.os.lang, di.os.tzname, di.os.tzoff);
- printf("\n");
- printf("Mounted filesystems:\n");
- printf("%s\n", di.mount.list);
-
- return 0;
-}
-
-void device_hw(struct device_info *di)
-{
- FILE *fp = NULL;
- char buf[128], *ptr = NULL;
-
- if(!(fp = fopen("/sys/devices/virtual/dmi/id/sys_vendor", "r")) || !fgets(di->hw.vendor, sizeof(di->hw.vendor), fp)) {
- strncpy(di->hw.vendor, "(unknown)", sizeof(di->hw.vendor) - 1);
- }
- if(fp) fclose(fp);
-
- if(!(fp = fopen("/sys/devices/virtual/dmi/id/product_name", "r")) || !fgets(di->hw.model, sizeof(di->hw.model), fp)) {
- di->hw.model[0] = '\n';
- }
- if(fp) fclose(fp);
-
- if(di->hw.vendor[strlen(di->hw.vendor) - 1] == '\n') di->hw.vendor[strlen(di->hw.vendor) - 1] = '\0';
- while(di->hw.vendor[strlen(di->hw.vendor) - 1] == ' ') di->hw.vendor[strlen(di->hw.vendor) - 1] = '\0';
- if(di->hw.model[strlen(di->hw.model) - 1] == '\n') di->hw.model[strlen(di->hw.model) - 1] = '\0';
- while(di->hw.model[strlen(di->hw.model) - 1] == ' ') di->hw.model[strlen(di->hw.model) - 1] = '\0';
-
- if(!(fp = fopen("/proc/cpuinfo", "r"))) return;
- while(fgets(buf, sizeof(buf), fp)) {
- if(!strncasecmp(buf, "model name", strlen("model name"))) {
- if((ptr = strstr(buf, ": ") + 2)) strncpy(di->hw.cpu, ptr, sizeof(di->hw.cpu) - 1);
- } else if(!strncasecmp(buf, "processor", strlen("processor"))) {
- if((ptr = strstr(buf, ": ") + 2)) di->hw.ncpu = atoi(ptr) + 1;
- }
- }
- fclose(fp);
-
- if((di->hw.cpu[0]) && (di->hw.cpu[strlen(di->hw.cpu) - 1] == '\n')) di->hw.cpu[strlen(di->hw.cpu) - 1] = '\0';
-
- return;
-}
-
-void device_stat(struct device_info *di)
-{
- FILE *fp = NULL;
- struct statvfs s;
- char buf[128], *ptr = NULL;
-
- if((fp = fopen("/proc/meminfo", "r"))) {
- while(fgets(buf, sizeof(buf), fp)) {
- if(!strncasecmp(buf, "MemTotal:", strlen("MemTotal:"))) {
- ptr = buf + strlen("MemTotal:");
- while(*ptr && (*ptr == ' ')) ptr++;
- di->stat.memt = atoll(ptr) / 1024;
- } else if(!strncasecmp(buf, "MemFree:", strlen("MemFree:"))) {
- ptr = buf + strlen("MemFree:");
- while(*ptr && (*ptr == ' ')) ptr++;
- di->stat.memf += atoll(ptr) / 1024;
- } else if(!strncasecmp(buf, "Cached:", strlen("Cached:"))) {
- ptr = buf + strlen("Cached:");
- while(*ptr && (*ptr == ' ')) ptr++;
- di->stat.memf += atoll(ptr) / 1024;
- }
- }
- fclose(fp);
- }
-
- if(di->stat.memf > di->stat.memt) di->stat.memf = di->stat.memt;
-
- if((ptr = getcwd(NULL, 0))) {
- if(statvfs(ptr, &s)) return;
- di->stat.diskt = (unsigned int)((unsigned long long)s.f_blocks * (unsigned long long)s.f_bsize / (unsigned long long)1073741824);
- di->stat.diskf = (unsigned int)((unsigned long long)s.f_bavail * (unsigned long long)s.f_bsize / (unsigned long long)1073741824);
- free(ptr);
- }
-
- return;
-}
-
-void device_power(struct device_info *di)
-{
- FILE *fp = NULL;
- char buf[128], *ptr = NULL;
-
- strncpy(di->power.ac, "(unavailable)", sizeof(di->power.ac) - 1);
- if(!(fp = fopen("/proc/acpi/ac_adapter/ADP1/state", "r"))) return;
- while(fgets(buf, sizeof(buf), fp)) {
- if(!strncasecmp(buf, "state:", strlen("state:"))) {
- ptr = buf + strlen("state:");
- while(*ptr && (*ptr == ' ')) ptr++;
- strncpy(di->power.ac, ptr, sizeof(di->power.ac) - 1);
- }
- }
- fclose(fp);
-
- if(di->power.ac[strlen(di->power.ac) - 1] == '\n') di->power.ac[strlen(di->power.ac) - 1] = '\0';
-
- return;
-}
-
-void device_os(struct device_info *di)
-{
- FILE *fp = NULL;
- struct utsname u;
- char buf[128], *ptr = NULL;
- time_t t;
- struct tm ts;
-
- do {
- strncpy(di->os.ver, "(unknown)", sizeof(di->os.ver) - 1);
-
- if((fp = fopen("/etc/lsb-release", "r"))) {
- while(fgets(buf, sizeof(buf), fp)) {
- if(!strncasecmp(buf, "DISTRIB_DESCRIPTION=", strlen("DISTRIB_DESCRIPTION="))) {
- ptr = buf + strlen("DISTRIB_DESCRIPTION=");
- while(*ptr && ((*ptr == ' ') || (*ptr == '"'))) ptr++;
- strncpy(di->os.ver, ptr, sizeof(di->os.ver) - 1);
- while((di->os.ver[strlen(di->os.ver) - 1] == '"') || (di->os.ver[strlen(di->os.ver) - 1] == '\n')) di->os.ver[strlen(di->os.ver) - 1] = '\0';
- }
- }
- } else if((fp = fopen("/etc/slackware-version", "r"))) {
- if(fgets(di->os.ver, sizeof(di->os.ver), fp)) break;
- } else if((fp = fopen("/etc/redhat-release", "r"))) {
- if(fgets(di->os.ver, sizeof(di->os.ver), fp)) break;
- } else if((fp = fopen("/etc/gentoo-release", "r"))) {
- if(fgets(di->os.ver, sizeof(di->os.ver), fp)) break;
- }
- } while(0);
- if(fp) fclose(fp);
-
- if(di->os.ver[strlen(di->os.ver) - 1] == '\n') di->os.ver[strlen(di->os.ver) - 1] = '\0';
-
- if(!uname(&u)) strncpy(di->os.arch, u.machine, sizeof(di->os.arch) - 1);
-
- if(!(ptr = getenv("LANG"))) ptr = "(unknown)";
- strncpy(di->os.lang, ptr, sizeof(di->os.lang) - 1);
-
- t = time(NULL);
- localtime_r(&t, &ts);
- strftime(di->os.tzname, sizeof(di->os.tzname), "%Z", &ts);
- strftime(di->os.tzoff, sizeof(di->os.tzoff), "%z", &ts);
- di->os.tzoff[6] = '\0';
- di->os.tzoff[5] = di->os.tzoff[4];
- di->os.tzoff[4] = di->os.tzoff[3];
- di->os.tzoff[3] = ':';
-
- return;
-}
-
-void device_user(struct device_info *di)
-{
- FILE *fp = NULL;
- char buf[128], *name, *gecos, *home, *ptr = NULL;
- unsigned int uid;
-
- di->user.uid = (unsigned int)getuid();
- di->user.gid = (unsigned int)getuid();
-
- if(!(fp = fopen("/etc/passwd", "r"))) return;
- while(fgets(buf, sizeof(buf), fp)) {
- if(!(ptr = strchr(buf, ':')) || !(ptr = strchr(++ptr, ':')) || (atoi(++ptr) != di->user.uid)) continue;
- if((gecos = strchr(ptr, ':')) && (gecos = strchr(++gecos, ':'))) *gecos++ = '\0';
- if((home = strchr(gecos, ':'))) *home++ = '\0';
- if((ptr = strchr(home, ':'))) *ptr = '\0';
- printf("%s %s\n", gecos, home);
- }
- fclose(fp);
-
- return;
-}
-
-void device_mount(struct device_info *di)
-{
- FILE *fp = NULL;
- char buf[512], *device = NULL, *mountpoint = NULL, *type = NULL, *ptr = NULL;
-
- if(!(fp = fopen("/etc/mtab", "r"))) return;
- while(fgets(buf, sizeof(buf), fp)) {
- device = buf;
- if((mountpoint = strchr(device, ' '))) *mountpoint++ = '\0';
- if((type = strchr(mountpoint, ' '))) *type++ = '\0';
- if((ptr = strchr(type, ' '))) *ptr = '\0';
- ptr = &di->mount.list[strlen(di->mount.list)];
- snprintf(ptr, sizeof(di->mount.list) - strlen(di->mount.list), "%s %s (%s)\n", device, mountpoint, type);
- }
- fclose(fp);
-
- if(di->mount.list[strlen(di->mount.list) - 1] == '\n') di->mount.list[strlen(di->mount.list) - 1] = '\0';
-
- return;
-}
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef COMMON_H_
-#define COMMON_H_
-
-void exit_with_err(const char *, const char *);
-void get_ssd(char *, uint8_t num);
-void get_kernel(char *, uint8_t num);
-void get_packs(char *);
-void get_taim(char *);
-void get_uptime(char *);
-void check_fan_vals(char *, uint_fast16_t *, uint8_t iterz);
-void split_n_index(char *);
-
-#if !defined(HAVE_SENSORS_SENSORS_H) && !defined(__OpenBSD__)
-void get_fans(char *);
-#endif /* !HAVE_SENSORS_SENSORS_H && !__OpenBSD__ */
-
-#if defined(__linux__)
-void get_temp(const char *, char *);
-#endif /* __linux__ */
-
-#if defined(__FreeBSD__)
-void get_temp(char *, uint_least32_t temp);
-#endif /* __FreeBSD__ */
-
-#if defined (HAVE_X11_XLIB_H)
-void set_status(const char *);
-#endif
-
-#if defined(HAVE_CDIO_CDIO_H) || defined(__linux__)
-void get_dvd(char *);
-#endif /* HAVE_CDIO_CDIO_H || __linux__ */
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
-void get_loadavg(char *);
-#endif
-
-#endif /* COMMON_H_ */
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef CPU_H_
-#define CPU_H_
-
-/* Inspired from https://en.wikipedia.org/wiki/CPUID and
- * llvm Host.cpp */
-#define CPU_VENDOR(x, z) __asm__("cpuid": "=b" (z) : "a" (x))
-#define CPU_FEATURE(x, z) __asm__("cpuid": "=a" (z) : "a" (x))
-#define CPU_REGS(x, y, z) __asm__( \
- "cpuid": \
- "=a" (z), \
- "=b" (y) \
- : "a" (x) \
-)
-#define CPU_STR2(regizter, a, b, c, d) __asm__( \
- "cpuid": \
- "=a" (a), \
- "=b" (b), \
- "=c" (c), \
- "=d" (d) \
- : "a" (regizter) \
-)
-#define CPU_ID_STR(regizter, b, c, d) __asm__( \
- "cpuid": \
- "=b" (b), \
- "=c" (c), \
- "=d" (d) \
- : "a" (regizter) \
-)
-#define IZMAX(x) (((x >> 8) & 0x0f) == 0x0f)
-
-#define SHFT(x) ((x) & 0x0f)
-#define SHFT2(x) ((x) & 0xff)
-#define AmD 0x68747541
-#define InteL 0x756e6547
-
-#if defined(__linux__)
-#define IDLE_NUM 3
-#define LOOP_ITERZ 10
-
-#else /* FreeBSD || OpenBSD */
-#define IDLE_NUM 4
-#define LOOP_ITERZ 5
-#endif /* __linux__ */
-
-/* --coresload related constant to determine
- * how many cpu cores/threads to try for detection */
-#define MAX_CORES 40
-
-void get_cpu(char *);
-void get_cores_load(char *);
-
-#if defined(__i386__) || defined(__i686__) || defined(__x86_64__)
-void get_cpu_clock_speed(char *);
-void get_cpu_info(char *);
-#endif
-
-
-#endif /* CPU_H_ */
+++ /dev/null
-/*
- 07/06/2015, 07/18/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef FUNCTIONS_H_
-#define FUNCTIONS_H_
-
-void get_ram(char *, uint8_t num);
-void get_voltage(char *);
-void get_mobo(char *);
-void get_mobo_temp(char *);
-void get_cpu_temp(char *);
-void get_battery(char *);
-void get_statio(char *, char *);
-
-#if defined(__linux__)
-void get_ssd_model(char *, char *);
-void get_loadavg(char *);
-
-#if defined(HAVE_SENSORS_SENSORS_H)
-void get_fans(char *);
-void match_feature(char *, uint8_t num);
-#endif /* HAVE_SENSORS_SENSORS_H */
-
-#endif /* __linux__ */
-
-
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
-void get_swapp(char *, uint8_t num);
-#endif /* __FreeBSD__ || __OpenBSD__ */
-
-#if defined(__OpenBSD__)
-void get_fans(char *);
-void match_feature(char *str1, uint8_t sens_type, uint8_t sens_num);
-#endif /* __OpenBSD__ */
-
-#endif /* FUNCTIONS_H_ */
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef NET_H_
-#define NET_H_
-
-#if defined(__linux__)
-#define NETFAM AF_PACKET
-#define RECVBYTS rx_bytes
-#define SENTBYTS tx_bytes
-#else
-
-#define NETFAM AF_LINK
-#define RECVBYTS ifi_ibytes
-#define SENTBYTS ifi_obytes
-#endif /* __linux__ */
-
-void get_net(char *, char *, uint8_t num);
-void get_nic_info2(char *, char *, uint8_t num);
-void get_ip_lookup(char *, char *);
-void get_nic_info(char *, char *);
-
-#endif /* NET_H_ */
+++ /dev/null
-/*
- 08/08/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef OPTIONS_H_
-#define OPTIONS_H_
-
-void parse_opts(int argc, char *argv[], char *combined);
-
-#endif /* OPTIONS_H_ */
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#ifndef SOUND_H_
-#define SOUND_H_
-
-#if defined (HAVE_ALSA_ASOUNDLIB_H) || defined(HAVE_SYS_SOUNDCARD_H) || \
- defined(HAVE_SOUNDCARD_H)
-void get_volume(char *);
-#endif
-
-void get_song(char *, uint8_t num);
-
-#endif /* SOUND_H_ */
+++ /dev/null
-/*
- 08/06/2016
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
-*/
-
-#include "config.h" /* Auto-generated */
-
-#if defined (HAVE_MPD_CLIENT_H)
-#include <mpd/client.h>
-#endif /* HAVE_MPD_CLIENT_H */
-
-#if defined (HAVE_ALSA_ASOUNDLIB_H)
-#include <alsa/asoundlib.h>
-#endif /* HAVE_ALSA_ASOUNDLIB_H */
-
-#if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_SOUNDCARD_H)
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-#if defined(HAVE_SOUNDCARD_H)
-#include <soundcard.h>
-#else
-#include <sys/soundcard.h>
-#endif /* HAVE_SOUNDCARD_H */
-
-#endif /* HAVE_SYS_SOUNDCARD_H || HAVE_SOUNDCARD_H */
-
-#include "include/headers.h"
-#include "prototypes/sound.h"
-
-#if defined (HAVE_ALSA_ASOUNDLIB_H)
-/* http://www.alsa-project.org/alsa-doc/alsa-lib/group___mixer.html
- * http://www.alsa-project.org/alsa-doc/alsa-lib/group___simple_mixer.html
- * for the return values */
-void
-get_volume(char *str1) {
- snd_mixer_t *handle = NULL;
- snd_mixer_elem_t *elem = NULL;
- snd_mixer_selem_id_t *s_elem = NULL;
- long int vol = 0L, max = 0L, min = 0L, percent = 0L;
-
- if (0 != (snd_mixer_open(&handle, 0))) {
- FUNC_FAILED("alsa");
- }
-
- if (0 != (snd_mixer_attach(handle, "default"))) {
- goto error;
- }
-
- if (0 != (snd_mixer_selem_register(handle, NULL, NULL))) {
- goto error;
- }
-
- if (0 != (snd_mixer_load(handle))) {
- goto error;
- }
-
- snd_mixer_selem_id_malloc(&s_elem);
- if (NULL == s_elem) {
- goto error;
- }
-
- snd_mixer_selem_id_set_name(s_elem, "Master");
- if (NULL == (elem = snd_mixer_find_selem(handle, s_elem))) {
- goto error;
- }
-
- if (0 != (snd_mixer_selem_get_playback_volume(elem, 0, &vol))) {
- goto error;
- }
- snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
-
- percent = 0L;
- if (0 != max) {
- percent = (vol * 100) / max;
- }
-
- snd_mixer_selem_id_free(s_elem);
- snd_mixer_close(handle);
-
- FILL_ARR(str1, "%ld", percent);
- return;
-
-error:
- if (NULL != s_elem) {
- snd_mixer_selem_id_free(s_elem);
- }
- if (NULL != handle) {
- snd_mixer_close(handle);
- }
- FUNC_FAILED("alsa");
-}
-#endif /* HAVE_ALSA_ASOUNDLIB_H */
-
-
-#if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_SOUNDCARD_H)
-/* Used the following resource:
- sources.freebsd.org/RELENG_9/src/usr.sbin/mixer/mixer.c
-*/
-void
-get_volume(char *str1) {
- int devmask = 0, volume = 0, fd = 0;
-
- if (-1 == (fd = open("/dev/mixer", O_RDONLY))) {
- exit_with_err(CANNOT_OPEN, "/dev/mixer");
- }
- if (-1 == (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask))) {
- CLOSE_FD(fd);
- exit_with_err(ERR, "SOUND_MIXER_READ_DEVMASK");
- }
- if (-1 == (ioctl(fd, MIXER_READ(0), &volume))) {
- CLOSE_FD(fd);
- exit_with_err(ERR, "MIXER_READ()");
- }
- CLOSE_FD(fd);
-
- FILL_ARR(str1, "%d", ((volume >> 8) & 0x7f));
-}
-#endif /* HAVE_SYS_SOUNDCARD_H || HAVE_SOUNDCARD_H */
-
-
-#if defined (HAVE_MPD_CLIENT_H)
-void
-get_song(char *str1, uint8_t num) {
-
- struct mpd_connection *conn = NULL;
- struct mpd_song *song = NULL;
-
- if (NULL == (conn = mpd_connection_new(NULL, 0, 0))) {
- return;
- }
- if (!(mpd_send_command(conn, "currentsong", NULL)) ||
- 0 != (mpd_connection_get_error(conn))) {
- goto error;
- }
- if (NULL == (song = mpd_recv_song(conn))) {
- goto error;
- }
-
- /* You can add more TAGs to be obtained,
- * look at /usr/include/mpd/tag.h
- */
- switch(num) {
- case 1:
- FILL_STR_ARR(1, str1, mpd_song_get_tag(song, MPD_TAG_TRACK, 0));
- break;
- case 2:
- FILL_STR_ARR(1, str1, mpd_song_get_tag(song, MPD_TAG_ARTIST, 0));
- break;
- case 3:
- FILL_STR_ARR(1, str1, mpd_song_get_tag(song, MPD_TAG_TITLE, 0));
- break;
- case 4:
- FILL_STR_ARR(1, str1, mpd_song_get_tag(song, MPD_TAG_ALBUM, 0));
- break;
- case 5:
- FILL_STR_ARR(1, str1, mpd_song_get_tag(song, MPD_TAG_DATE, 0));
- break;
- case 6:
- FILL_STR_ARR(1, str1, mpd_song_get_uri(song));
- break;
- }
-
-error:
- if (NULL != song) {
- mpd_song_free(song);
- }
- if (NULL != conn) {
- mpd_connection_free(conn);
- }
- return;
-}
-
-#else
-
-void
-get_song(char *str1, uint8_t num) {
- FILE *fp;
- char buf[100], temp[100], *ptr;
- const char *tagz[] = { "artist", "title", "album", "date" };
- const char *idx_tagz = ((6 != num) ? tagz[num-2] : "ohsnap");
-
- if (NULL == (fp = popen("cmus-remote -Q 2> /dev/null", "r"))) {
- return;
- }
-
- while (true) {
- if (NULL == (fgets(buf, 99, fp))) {
- break;
- }
- if (6 == num) {
- if ('f' == buf[0] && 'i' == buf[1] && 'l' == buf[2]) {
- CHECK_SSCANF(buf, "%*s %[^\n]", temp);
- if (NULL != (ptr = strrchr(temp, '/'))) {
- for (; *ptr; ptr++) {
- if ('/' != *ptr) {
- *str1++ = *ptr;
- }
- }
- *str1 = '\0';
- }
- break;
- }
- } else {
- if ('t' == buf[0] && 'a' == buf[1] && 'g' == buf[2]) {
- CHECK_SSCANF(buf, "%*s %s", temp);
- if (STREQ(idx_tagz, temp)) {
- CHECK_SSCANF(buf, "%*s %*s %[^\n]", str1);
- break;
- }
- }
- if ('s' == buf[0] && 't' == buf[1] && 'r' == buf[2]) {
- if (1 != (num-2)) {
- CHECK_SSCANF(buf, "%*s %[^\n]", str1);
- break;
- }
- }
- }
- }
-
- if (-1 == (pclose(fp))) {
- exit_with_err(CANNOT_CLOSE, "popen()");
- }
-}
-#endif /* HAVE_MPD_CLIENT_H */
+++ /dev/null
-#define arch1_width 8
-#define arch1_height 8
-static unsigned char arch1_bits[] = {
- 0x18, 0x18, 0x3c, 0x3c, 0x7e, 0x66, 0xe7, 0xc3};
+++ /dev/null
-#define bat_full_width 8
-#define bat_full_height 8
-static unsigned char bat_full_bits[] = {
- 0x18, 0x7E, 0x42, 0x5A, 0x5A, 0x5A, 0x42, 0x7E };
+++ /dev/null
-#define clock5_width 8
-#define clock5_height 8
-static unsigned char clock5_bits[] = {
- 0x00, 0x7c, 0xee, 0xee, 0x8e, 0xfe, 0xfe, 0x7c};
+++ /dev/null
-#define cpu13_width 8
-#define cpu13_height 8
-static unsigned char cpu13_bits[] = {
- 0xdb, 0xc3, 0x3c, 0xbd, 0xbd, 0x3c, 0xc3, 0xdb};
+++ /dev/null
-#define diskette_width 8
-#define diskette_height 8
-static unsigned char diskette_bits[] = {
- 0xFF, 0x81, 0x81, 0x81, 0xBD, 0xB5, 0xB5, 0xFE };
+++ /dev/null
-#define cpu15_width 8
-#define cpu15_height 8
-static unsigned char cpu15_bits[] = {
- 0x02, 0xf2, 0x3e, 0x26, 0x64, 0x7c, 0x4f, 0x40};
+++ /dev/null
-#define mem1_width 8
-#define mem1_height 8
-static unsigned char mem1_bits[] = {
- 0xaa, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0xaa};
+++ /dev/null
-#define grid_width 8
-#define grid_height 8
-static unsigned char grid_bits[] = {
- 0xdb, 0xdb, 0x00, 0xdb, 0xdb, 0x00, 0xdb, 0xdb};
+++ /dev/null
-#define cpu_width 16
-#define cpu_height 15
-static unsigned char cpu_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x40, 0x10, 0x40, 0x10,
- 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x70, 0x1c, 0x78, 0x1e, 0x30, 0x0c,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+++ /dev/null
-#define net_width 8
-#define net_height 8
-static unsigned char net_wired_bits[] = {
- 0x00, 0x1C, 0x1C, 0x7F, 0x7F, 0x7F, 0x55, 0x7F };
+++ /dev/null
-#define info_width 8
-#define info_height 8
-static unsigned char info_bits[] = {
- 0x38, 0x38, 0x00, 0x3C, 0x38, 0x38, 0x38, 0x7C };
+++ /dev/null
-#define temp1_width 8
-#define temp1_height 8
-static unsigned char temp1_bits[] = {
- 0x30, 0xf0, 0x30, 0xf0, 0x30, 0x78, 0x78, 0x30};
+++ /dev/null
-#define net_up_03_width 8
-#define net_up_03_height 8
-static unsigned char net_up_03_bits[] = {
- 0x10, 0x38, 0x7C, 0xFE, 0x38, 0x38, 0x38, 0x38 };
+++ /dev/null
-#define vol1_width 8
-#define vol1_height 8
-static unsigned char vol1_bits[] = {
- 0x08, 0x4c, 0x8f, 0xaf, 0xaf, 0x8f, 0x4c, 0x08};
+++ /dev/null
-#define ac11_width 8
-#define ac11_height 8
-static unsigned char ac11_bits[] = {
- 0x40, 0x20, 0x10, 0xf8, 0x40, 0x20, 0x10, 0x08};