!extra/FreeBSD/Makefile
-!extra/_pinkybar
-!extra/man_template.pdc
+!extra/zsh/_pinkybar
+!doc/man_template.pdc
!extra/Gentoo/app-admin/pinky/*
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 &
-```
+Copy the code from extra/scripts/dwm.sh or `exec` it from **xinitrc** or the script used to start dwm.
## 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
+cp -r extra/xbm_icons/*.xbm $HOME/.xmonad/icons
bash bootstrap distro
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/pinkybar" -LTrspkvfmdVt
- sleep 2
-done | dzen2 -w 1800 -x 130 -ta r -fn '-*-dejavusans-*-r-*-*-11-*-*-*-*-*-*-*' &
-```
+Copy the code from extra/scripts/xmonad.sh or `exec` it from **xinitrc** or the script used to start xmonad.
## Installation in FreeBSD
make install
```
-Send a request to the FreeBSD mail list and request the OpenBSD sensors API to be ported.
-
+Send a request to the FreeBSD mailing list and request the OpenBSD sensors API to be ported.
## Installation in OpenBSD
make install
```
-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}"/pinkybar -LTrspkvfmdVt
- sleep 2
- done | "${location}"/ncurses
-}
-```
-
-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
-```
+Copy the code from extra/scripts/pinky-curses.sh and extra/misc/.Xresources
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.
**Warning !!! OpenBSD users !!!**
-The majority of SCN\* macros differs from their PRI\* cousins. When you define unsigned int you should always follow the C standards that made it clear what format specifier unsigned int should use, unfortunately the majority of OpenBSD's own libc SCN\* macros managed not to follow the standard. "hu" and "hhu" are not unsigned int format specifiers, tried to get in touch with OpenBSD devs, reported this bug but no one responded.
-
-If they wanted to use specific integer type, then they should define it as such earlier. 8 bit integer is the smallest integer type in existance and for sure it cannot represent the 32 bit UINT\_MAX number. glibc uses the maximum unsigned char and signed char for all int8\_t, int\_least8\_t, int\_fast8\_t and uint8\_t, uint\_least8\_t, uint\_fast8\_t , and yes glibc defines corrent PRI\* and SCN\* format specifier macros to match that integer type.
-
-It's not like to mistake the float format specifier with the "double" one.
-
-It's dirty trick to let the complier do the conversion for you to lower the integer type and not follow the standards to define it as such earlier.
-
-You'll be the judge in here, read the following code and try to understand what my intentions are:
-
-```cpp
-unsigned long long int small_int = 240;
-
-printf("%hhu\n", small_int);
-```
-
-What I've done wrong in the above example by following the OpenBSD "standard" ? Way to go OpenBSD !
-
-```cpp
-/* machine/_types.h */
-typedef unsigned int __uint32_t;
-
-typedef __uint32_t __uint_fast8_t;
-typedef __uint32_t __uint_fast16_t;
-
-/* stdint.h */
-typedef __uint_fast8_t uint_fast8_t;
-typedef __uint_fast16_t uint_fast16_t;
-
-/* inttypes.h */
-#define PRIuFAST8 "u" /* uint_fast8_t */
-#define SCNuFAST8 "hhu" /* uint_fast8_t */
-
-#define PRIuFAST16 "u" /* uint_fast16_t */
-#define SCNuFAST16 "hu" /* uint_fast16_t */
-```
-
-The bug was submitted and have not been added to marc.info
-
-```cpp
-/* test.c
-egcc -Wall -Wextra -std=c99 -pedantic -Wconversion -O2 test.c -o /tmp/test
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-int main(void) {
- char acc[] = "Remaining: 99000";
- uint_fast8_t cur = 0, started = 99000;
-
- printf("%s\n", acc);
- if (EOF == (sscanf(acc, "%*s %"SCNuFAST8, &cur))) {
- return EXIT_FAILURE;
- }
- printf("%s " "%"PRIuFAST8 " %s " "%"PRIuFAST8 "\n",
- "Started with: $", started,
- "The current balance now: $", cur
- );
-
- return EXIT_SUCCESS;
-}
-```
+The majority of SCN\* macros differs from their PRI\* cousins. And I cannot guarantee the accuracy of fixed width integers when OpenBSD own libc managed to use different format specifiers. Read extra/misc/openbsd\_bugs.md for more details.
## Opt-in requirements
Open up your browser and navigate to 127.0.0.1:7634 and you'll get instant temperature report back to you.
-The "init" lock-in for those of you that cannot choose between udev or eudev puts me in position not rely on libatasmart, regardless how neat the library is.
-
-```cpp
-/* gcc -Wall -Wextra -O2 skdump.c -latasmart -o test */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <atasmart.h>
-
-int main(void) {
- uint64_t mkelvin = 0;
- const char *device = "/dev/sda";
- SkDisk *d = NULL;
-
- if (-1 == (sk_disk_open(device, &d))) {
- fprintf(stderr, "Failed to open disk %s: %s\n", device, strerror(errno));
- return 1;
- }
-
- if (-1 == (sk_disk_smart_read_data(d))) {
- fprintf(stderr, "Failed to read SMART data: %s\n", strerror(errno));
- goto finish;
- }
-
- if (-1 == (sk_disk_smart_get_temperature(d, &mkelvin))) {
- fprintf(stderr, "Failed to get temperature: %s\n", strerror(errno));
- goto finish;
- }
-
- printf("%llu\n", (unsigned long long)mkelvin);
-
-finish:
- if (NULL != d) {
- sk_disk_free(d);
- }
- return 0;
-}
-```
+The "init" lock-in for those of you that cannot choose between udev or eudev puts me in position not rely on libatasmart, regardless how neat the library is. There is stripped example program in extra/misc/skdump.c if you are curious to check and test libatasmart.
Linux camp end.
To read the drive temperature from S.M.A.R.T **--with-smartemp**:
* smartmontools
-* perl (for the "one line" script below)
Execute the following command as root `visudo` and append:
frost ALL=NOPASSWD:/usr/sbin/smartctl
```
-Put the following code in xinitrc or the script used to start your DE/WM.
-
-```bash
-while true; do
- sudo smartctl -a /dev/sda | \
- perl -Mstrict -Mwarnings -ne '
- my ($fifed_txt) = $_;
- my @arr = split(" ", $fifed_txt);
-
- if ($arr[1] and lc $arr[1] eq "temperature_celsius") {
- printf("%d\n",(($arr[9] and $arr[9] =~ /\d+/) ? $arr[9] : 0));
- }' > /tmp/pinkytemp
-
- sleep 20
-done &
-```
+Copy the code from extra/scripts/drive-temperature.sh or `exec` it from **xinitrc** or the script used to start your DE/WM.
To get the sound volume level:
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"
-}
-
-port "6600"
-bind_to_address "127.0.0.1"
-```
-
-FreeBSD conf, same as the Linux one, you'll have to add the "musicpd" daemon user on your own:
-
-```nginx
-user "musicpd"
-
-audio_output {
- type "oss"
- name "My sound card"
- mixer_type "software"
-}
-```
-
-OpenBSD conf, same as the FreeBSD one, just replace audio\_output with:
-
-```nginx
-audio_output {
- type "ao"
- name "My sound card"
- mixer_type "software"
-}
-```
+If you've never used mpd before copy the example configuration from extra/mpd according to your OS.
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.
main_makefile=('
SUBDIRS = src
- dist_man_MANS = extra/pinkybar.1
+ dist_man_MANS = doc/pinkybar.1
# To satisfy make dist
EXTRA_DIST = \
README.md \
.gitignore \
m4 \
- xbm_icons \
+ doc \
extra
# uses tabs
'options.c'
'net.c'
'weather.c'
+ 'smart.c'
'prototypes/cpu.h'
'prototypes/common.h'
'prototypes/functions.h'
'prototypes/options.h'
'prototypes/weather.h'
+ 'prototypes/smart.h'
'include/headers.h'
'include/options_constants.h'
-\_pinkybar is zsh completion. This file will not be installed automatically.
-
-pinkybar.1 is the man page.
-
To re-create the man page you'll have to install the whole pandoc suite and invoke the following commands:
```bash
% pinkybar(1) manual
% Aaron Caffrey
-% Oktoberfest 13, 2016
+% Oktoberfest 23, 2016
# NAME
This man page is converted from markdown, and some information might not look good and/or have been stripped during the automated process.
.\"t
-.TH "pinkybar" "1" "Oktoberfest 13, 2016" "manual" ""
+.TH "pinkybar" "1" "Oktoberfest 23, 2016" "manual" ""
.SH NAME
.PP
This man page is converted from markdown, and some information might not
\f[]
.fi
.PP
-To see the currently played song name add \f[B]\[en]with\-mpd\f[] to
-configure.
-.PP
-To disable the colours you can add \f[B]\[en]without\-colours\f[] to
-configure.
-.PP
-Put the following in your \f[B]xinitrc\f[] or the script used to start
-dwm.
-.IP
-.nf
-\f[C]
-#\ 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\ &
-\f[]
-.fi
+Copy the code from extra/scripts/dwm.sh or \f[C]exec\f[] it from
+\f[B]xinitrc\f[] or the script used to start dwm.
.SS Installation for xmonad (or other WM)
.IP
.nf
\f[C]
#\ Copy\ the\ xbm\ icons
mkdir\ \-p\ \-\-mode=700\ $HOME/.xmonad/icons
-cp\ \-r\ xbm_icons/*.xbm\ $HOME/.xmonad/icons
+cp\ \-r\ extra/xbm_icons/*.xbm\ $HOME/.xmonad/icons
bash\ bootstrap\ distro
\f[]
.fi
.PP
-To see the currently played song name add \f[B]\[en]with\-mpd\f[] to
-configure.
-.PP
-Put the following in your \f[B]xinitrc\f[] or the script used to start
-xmonad.
-.IP
-.nf
-\f[C]
-#\ Execute\ the\ "statusbar"\ program\ every\ 2\ secs
-while\ true;\ do
-\ \ #\ scroll\ a\ few\ lines\ up\ to\ see\ the\ rest\ options
-\ \ "$HOME/.cache/bin/pinkybar"\ \-LTrspkvfmdVt
-\ \ sleep\ 2
-done\ |\ dzen2\ \-w\ 1800\ \-x\ 130\ \-ta\ r\ \-fn\ \[aq]\-*\-dejavusans\-*\-r\-*\-*\-11\-*\-*\-*\-*\-*\-*\-*\[aq]\ &
-\f[]
-.fi
+Copy the code from extra/scripts/xmonad.sh or \f[C]exec\f[] it from
+\f[B]xinitrc\f[] or the script used to start xmonad.
.SS Installation in FreeBSD
.PP
FreeBSD has no other way than using the module specific convention to
\f[]
.fi
.PP
-Send a request to the FreeBSD mail list and request the OpenBSD sensors
-API to be ported.
+Send a request to the FreeBSD mailing list and request the OpenBSD
+sensors API to be ported.
.SS Installation in OpenBSD
.PP
Before even executing the \f[B]bootstrap\f[] script, you'll have to do
\f[]
.fi
.PP
-Put the following in your shell config as function or alias.
-.IP
-.nf
-\f[C]
-pinky()\ {
-\ \ location="${HOME}/.cache/bin"
-
-\ \ while\ true;\ do
-\ \ \ \ #\ scroll\ a\ few\ lines\ up\ to\ see\ the\ rest\ options
-\ \ \ \ "${location}"/pinkybar\ \-LTrspkvfmdVt
-\ \ \ \ sleep\ 2
-\ \ done\ |\ "${location}"/ncurses
-}
-\f[]
-.fi
-.PP
-Test it:
-.IP
-.nf
-\f[C]
-pinky\ \ #\ Press\ CTRL\ +\ C\ to\ stop\ the\ program
-\f[]
-.fi
-.PP
-Put the following in \f[B]~/.Xresources\f[]
-.IP
-.nf
-\f[C]
-!\ 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
-\f[]
-.fi
+Copy the code from extra/scripts/pinky\-curses.sh and
+extra/misc/.Xresources
.PP
Force your non xterm/urxvt terminal emulator to use the newer
xterm/urxvt colours.
\f[B]Warning !!! OpenBSD users !!!\f[]
.PP
The majority of SCN* macros differs from their PRI* cousins.
-When you define unsigned int you should always follow the C standards
-that made it clear what format specifier unsigned int should use,
-unfortunately the majority of OpenBSD's own libc SCN* macros managed not
-to follow the standard.
-\[lq]hu\[rq] and \[lq]hhu\[rq] are not unsigned int format specifiers,
-tried to get in touch with OpenBSD devs, reported this bug but no one
-responded.
-.PP
-If they wanted to use specific integer type, then they should define it
-as such earlier.
-8 bit integer is the smallest integer type in existance and for sure it
-cannot represent the 32 bit UINT_MAX number.
-glibc uses the maximum unsigned char and signed char for all int8_t,
-int_least8_t, int_fast8_t and uint8_t, uint_least8_t, uint_fast8_t , and
-yes glibc defines corrent PRI* and SCN* format specifier macros to match
-that integer type.
-.PP
-It's not like to mistake the float format specifier with the
-\[lq]double\[rq] one.
-.PP
-It's dirty trick to let the complier do the conversion for you to lower
-the integer type and not follow the standards to define it as such
-earlier.
-.PP
-You'll be the judge in here, read the following code and try to
-understand what my intentions are:
-.IP
-.nf
-\f[C]
-unsigned\ long\ long\ int\ small_int\ =\ 240;
-
-printf("%hhu\\n",\ small_int);
-\f[]
-.fi
-.PP
-What I've done wrong in the above example by following the OpenBSD
-\[lq]standard\[rq] ?
-Way to go OpenBSD !
-.IP
-.nf
-\f[C]
-/*\ machine/_types.h\ */
-typedef\ unsigned\ int\ \ \ \ \ \ \ \ __uint32_t;
-
-typedef\ __uint32_t\ \ \ \ \ \ __uint_fast8_t;
-typedef\ __uint32_t\ \ \ \ \ \ __uint_fast16_t;
-
-/*\ stdint.h\ */
-typedef\ __uint_fast8_t\ \ \ \ \ \ uint_fast8_t;
-typedef\ __uint_fast16_t\ \ \ \ \ uint_fast16_t;
-
-/*\ inttypes.h\ */
-#define\ PRIuFAST8\ \ \ \ \ \ \ "u"\ \ \ \ \ /*\ uint_fast8_t\ */
-#define\ SCNuFAST8\ \ \ \ \ \ \ "hhu"\ \ \ \ \ \ \ /*\ uint_fast8_t\ */
-
-#define\ PRIuFAST16\ \ \ \ \ \ "u"\ \ \ \ \ /*\ uint_fast16_t\ */
-#define\ SCNuFAST16\ \ \ \ \ \ "hu"\ \ \ \ \ \ \ \ /*\ uint_fast16_t\ */
-\f[]
-.fi
-.PP
-The bug was submitted and have not been added to marc.info
-.IP
-.nf
-\f[C]
-/*\ test.c
-egcc\ \-Wall\ \-Wextra\ \-std=c99\ \-pedantic\ \-Wconversion\ \-O2\ test.c\ \-o\ /tmp/test
-\ */
-#include\ <stdio.h>
-#include\ <stdlib.h>
-#include\ <inttypes.h>
-
-int\ main(void)\ {
-\ \ char\ acc[]\ =\ "Remaining:\ 99000";
-\ \ uint_fast8_t\ cur\ =\ 0,\ started\ =\ 99000;
-
-\ \ printf("%s\\n",\ acc);
-\ \ if\ (EOF\ ==\ (sscanf(acc,\ "%*s\ %"SCNuFAST8,\ &cur)))\ {
-\ \ \ \ return\ EXIT_FAILURE;
-\ \ }
-\ \ printf("%s\ "\ "%"PRIuFAST8\ "\ %s\ "\ "%"PRIuFAST8\ "\\n",
-\ \ \ "Started\ with:\ $",\ started,
-\ \ \ "The\ current\ balance\ now:\ $",\ cur
-\ \ );
-
-\ \ return\ EXIT_SUCCESS;
-}
-\f[]
-.fi
+And I cannot guarantee the accuracy of fixed width integers when OpenBSD
+own libc managed to use different format specifiers.
+Read extra/misc/openbsd_bugs.md for more details.
.SS Opt\-in requirements
.PP
Linux camp:
The \[lq]init\[rq] lock\-in for those of you that cannot choose between
udev or eudev puts me in position not rely on libatasmart, regardless
how neat the library is.
-.IP
-.nf
-\f[C]
-/*\ gcc\ \-Wall\ \-Wextra\ \-O2\ skdump.c\ \-latasmart\ \-o\ test\ */
-#include\ <stdio.h>
-#include\ <string.h>
-#include\ <errno.h>
-
-#include\ <atasmart.h>
-
-int\ main(void)\ {
-\ \ uint64_t\ mkelvin\ =\ 0;
-\ \ const\ char\ *device\ =\ "/dev/sda";
-\ \ SkDisk\ *d\ =\ NULL;
-
-\ \ if\ (\-1\ ==\ (sk_disk_open(device,\ &d)))\ {
-\ \ \ \ fprintf(stderr,\ "Failed\ to\ open\ disk\ %s:\ %s\\n",\ device,\ strerror(errno));
-\ \ \ \ return\ 1;
-\ \ }
-
-\ \ if\ (\-1\ ==\ (sk_disk_smart_read_data(d)))\ {
-\ \ \ \ fprintf(stderr,\ "Failed\ to\ read\ SMART\ data:\ %s\\n",\ strerror(errno));
-\ \ \ \ goto\ finish;
-\ \ }
-
-\ \ if\ (\-1\ ==\ (sk_disk_smart_get_temperature(d,\ &mkelvin)))\ {
-\ \ \ \ fprintf(stderr,\ "Failed\ to\ get\ temperature:\ %s\\n",\ strerror(errno));
-\ \ \ \ goto\ finish;
-\ \ }
-
-\ \ printf("%llu\\n",\ (unsigned\ long\ long)mkelvin);
-
-finish:
-\ \ if\ (NULL\ !=\ d)\ {
-\ \ \ \ sk_disk_free(d);
-\ \ }
-\ \ return\ 0;
-}
-\f[]
-.fi
+There is stripped example program in extra/misc/skdump.c if you are
+curious to check and test libatasmart.
.PP
Linux camp end.
.PP
\f[B]\[en]with\-smartemp\f[]:
.IP \[bu] 2
smartmontools
-.IP \[bu] 2
-perl (for the \[lq]one line\[rq] script below)
.PP
Execute the following command as root \f[C]visudo\f[] and append:
.IP
\f[]
.fi
.PP
-Put the following code in xinitrc or the script used to start your
-DE/WM.
-.IP
-.nf
-\f[C]
-while\ true;\ do
-\ \ sudo\ smartctl\ \-a\ /dev/sda\ |\ \\
-\ \ \ \ perl\ \-Mstrict\ \-Mwarnings\ \-ne\ \[aq]
-\ \ \ \ \ \ my\ ($fifed_txt)\ =\ $_;
-\ \ \ \ \ \ my\ \@arr\ =\ split("\ ",\ $fifed_txt);
-
-\ \ \ \ \ \ if\ ($arr[1]\ and\ lc\ $arr[1]\ eq\ "temperature_celsius")\ {
-\ \ \ \ \ \ \ \ printf("%d\\n",(($arr[9]\ and\ $arr[9]\ =~\ /\\d+/)\ ?\ $arr[9]\ :\ 0));
-\ \ \ \ \ \ }\[aq]\ >\ /tmp/pinkytemp
-
-\ \ sleep\ 20
-done\ &
-\f[]
-.fi
+Copy the code from extra/scripts/drive\-temperature.sh or \f[C]exec\f[]
+it from \f[B]xinitrc\f[] or the script used to start your DE/WM.
.PP
To get the sound volume level:
.IP \[bu] 2
The FreeBSD users will notice that \[lq]mpd\[rq] is named
\[lq]musicpd\[rq].
.PP
-Here's an example of my \f[B]/etc/mpd.conf\f[] (linux)
-.IP
-.nf
-\f[C]
-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"
-}
-
-port\ "6600"
-bind_to_address\ "127.0.0.1"
-\f[]
-.fi
-.PP
-FreeBSD conf, same as the Linux one, you'll have to add the
-\[lq]musicpd\[rq] daemon user on your own:
-.IP
-.nf
-\f[C]
-user\ "musicpd"
-
-audio_output\ {
-\ \ type\ "oss"
-\ \ name\ "My\ sound\ card"
-\ \ mixer_type\ "software"
-}
-\f[]
-.fi
-.PP
-OpenBSD conf, same as the FreeBSD one, just replace audio_output with:
-.IP
-.nf
-\f[C]
-audio_output\ {
-\ \ type\ "ao"
-\ \ name\ "My\ sound\ card"
-\ \ mixer_type\ "software"
-}
-\f[]
-.fi
+If you've never used mpd before copy the example configuration from
+extra/mpd according to your OS.
.PP
Keep an eye on the \f[B]log file size\f[] if you are using raspberry pi
(or equivalent device) that streams the music, make sure that it's
--- /dev/null
+! 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.
+
+! 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
--- /dev/null
+The majority of SCN* macros differs from their PRI* cousins. When you define unsigned int you should always follow the C standards that made it clear what format specifier unsigned int should use, unfortunately the majority of OpenBSD's own libc SCN* macros managed not to follow the standard. "hu" and "hhu" are not unsigned int format specifiers, tried to get in touch with OpenBSD devs, reported this bug but no one responded.
+
+If they wanted to use specific integer type, then they should define it as such earlier. 8 bit integer is the smallest integer type in existance and for sure it cannot represent the 32 bit UINT_MAX number. glibc uses the maximum unsigned char and signed char for all int8_t, int_least8_t, int_fast8_t and uint8_t, uint_least8_t, uint_fast8_t , and yes glibc defines corrent PRI* and SCN* format specifier macros to match that integer type.
+
+It's not like to mistake the float format specifier with the "double" one.
+
+It's dirty trick to let the complier do the conversion for you to lower the integer type and not follow the standards to define it as such earlier.
+
+The definitions in OpenBSD own libc:
+
+```cpp
+/* machine/_types.h */
+typedef unsigned int __uint32_t;
+
+typedef __uint32_t __uint_fast8_t;
+typedef __uint32_t __uint_fast16_t;
+
+/* stdint.h */
+typedef __uint_fast8_t uint_fast8_t;
+typedef __uint_fast16_t uint_fast16_t;
+
+/* inttypes.h */
+#define PRIuFAST8 "u" /* uint_fast8_t */
+#define SCNuFAST8 "hhu" /* uint_fast8_t */
+
+#define PRIuFAST16 "u" /* uint_fast16_t */
+#define SCNuFAST16 "hu" /* uint_fast16_t */
+```
+
+Sample program to simulate the bug:
+
+```cpp
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+int main(void) {
+ char acc[] = "Remaining: 99000";
+ uint_fast8_t cur = 0, started = 99000;
+
+ printf("%s\n", acc);
+ if (EOF == (sscanf(acc, "%*s %"SCNuFAST8, &cur))) {
+ return EXIT_FAILURE;
+ }
+ printf("%s " "%"PRIuFAST8 " %s " "%"PRIuFAST8 "\n",
+ "Started with: $", started,
+ "The current balance now: $", cur
+ );
+
+ return EXIT_SUCCESS;
+}
+```
+
+Amusing representation of the above code:
+
+```cpp
+unsigned long long int small_int = 240;
+
+printf("%hhu\n", small_int);
+```
--- /dev/null
+/*
+ * Sample program to demonstate the usage of libatasmart
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <atasmart.h>
+
+int main(void) {
+ uint64_t mkelvin = 0;
+ const char *device = "/dev/sda";
+ SkDisk *d = NULL;
+
+ if (-1 == (sk_disk_open(device, &d))) {
+ fprintf(stderr, "Failed to open disk %s: %s\n", device, strerror(errno));
+ return 1;
+ }
+
+ if (-1 == (sk_disk_smart_read_data(d))) {
+ fprintf(stderr, "Failed to read SMART data: %s\n", strerror(errno));
+ goto finish;
+ }
+
+ if (-1 == (sk_disk_smart_get_temperature(d, &mkelvin))) {
+ fprintf(stderr, "Failed to get temperature: %s\n", strerror(errno));
+ goto finish;
+ }
+
+ printf("%llu\n", (unsigned long long)mkelvin);
+
+finish:
+ if (NULL != d) {
+ sk_disk_free(d);
+ }
+ return 0;
+}
--- /dev/null
+\*BSD users should add the "musicpd" daemon user on their own
--- /dev/null
+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 "musicpd"
+
+audio_output {
+ type "oss"
+ name "My sound card"
+ mixer_type "software"
+}
+
+port "6600"
+bind_to_address "127.0.0.1"
--- /dev/null
+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"
+}
+
+port "6600"
+bind_to_address "127.0.0.1"
--- /dev/null
+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 "musicpd"
+
+audio_output {
+ type "ao"
+ name "My sound card"
+ mixer_type "software"
+}
+
+port "6600"
+bind_to_address "127.0.0.1"
--- /dev/null
+#!/usr/bin/env bash
+
+# 10/23/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.
+
+# Edit /dev/sda according to
+# your operating system drive naming
+# convetion
+
+while true; do
+ sudo smartctl -a /dev/sda | \
+ perl -Mstrict -Mwarnings -ne '
+ my ($fifed_txt) = $_;
+ my @arr = split(" ", $fifed_txt);
+
+ if ($arr[1] and lc $arr[1] eq "temperature_celsius") {
+ printf("%d\n",(($arr[9] and $arr[9] =~ /\d+/) ? $arr[9] : 0));
+ }' > /tmp/pinkytemp
+
+ sleep 20
+done &
--- /dev/null
+#!/usr/bin/env bash
+
+# 10/23/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.
+
+# Execute the "statusbar" program every 2 secs
+while true; do
+ "${HOME}"/.cache/bin/pinkybar -LTrspkvfmdVt
+ sleep 2
+done &
--- /dev/null
+#!/usr/bin/env bash
+
+# 10/23/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.
+
+pinky() {
+ location="${HOME}/.cache/bin"
+
+ while true; do
+ "${location}"/pinkybar -LTrspkvfmdVt
+ sleep 2
+ done | "${location}"/ncurses
+}
--- /dev/null
+#!/usr/bin/env bash
+
+# 10/23/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.
+
+# Execute the "statusbar" program every 2 secs
+while true; do
+ "${HOME}"/.cache/bin/pinkybar -LTrspkvfmdVt
+ sleep 2
+done | dzen2 -w 1800 -x 130 -ta r -fn \
+ '-*-dejavusans-*-r-*-*-11-*-*-*-*-*-*-*' &
dnl the --with-sensors switch
AC_DEFUN([TEST_SENSORS],[
SENSORS_LIBS=""
- WITH_SMARTEMP=0
AC_ARG_WITH([sensors],
AS_HELP_STRING([--with-sensors],
[with_sensors=no]
)
- AC_ARG_WITH([smartemp],
- AS_HELP_STRING([--with-smartemp],
- [Read the drive temperature from S.M.A.R.T]),
- [],
- [with_smartemp=no]
- )
-
ifdef([LINUKS],[
AS_IF([test "x$with_sensors" = "xyes"], [
AC_CHECK_HEADERS([sensors/sensors.h], [
],[
])
- AS_IF([test "x$with_smartemp" = "xyes"], [
- WITH_SMARTEMP=1
- ])
-
-
AC_SUBST(SENSORS_LIBS)
- AC_DEFINE_UNQUOTED([WITH_SMARTEMP],[$WITH_SMARTEMP],[Read the drive temperature from S.M.A.R.T])
ifdef([LINUKS],[
AS_IF([test "x$with_sensors" = "xyes"], [
[with_drivetemp=no]
)
+ AC_ARG_WITH([smartemp],
+ AS_HELP_STRING([--with-smartemp],
+ [Read the drive temperature from S.M.A.R.T]),
+ [],
+ [with_smartemp=no]
+ )
+
AS_IF([test "x$with_weather" = "xyes" || test "x$with_drivetemp" = "xyes"], [
CHECK_CFLAGZ([-O0])
}
*str1 = '\0';
}
-
-
-#if WITH_SMARTEMP == 1
-void
-get_drivetemp(char *str1) {
- FILE *fp = NULL;
- uint_fast16_t temp = 0;
- const char *pinkytemp = "/tmp/pinkytemp";
-
- FILL_STR_ARR(1, str1, "0");
-
- if (NULL == (fp = fopen(pinkytemp, "r"))) {
- return;
- }
- CHECK_FSCANF(fp, SCAN_UFINT, &temp);
- CLOSE_X(fp);
-
- FILL_ARR(str1, UFINT, temp);
-}
-#endif /* WITH_SMARTEMP */
#include <sys/sysinfo.h>
-#if WITH_DRIVETEMP == 1
-#include <ctype.h>
-#include <curl/curl.h>
-#endif /* WITH_DRIVETEMP */
-
#if defined(HAVE_SENSORS_SENSORS_H)
#include <sensors/sensors.h>
#endif /* HAVE_SENSORS_SENSORS_H */
#include "include/headers.h"
-#if WITH_DRIVETEMP == 1
-static size_t read_temp_data_cb(char *, size_t size, size_t nmemb, char *);
-#endif /* WITH_DRIVETEMP */
-
void
get_ram(char *str1, uint8_t num) {
uintmax_t used = 0, total = 0;
void
get_ssd_model(char *str1, char *str2) {
- FILE *fp;
+ FILE *fp = NULL;
char model[VLA];
FILL_ARR(model, "%s%s%s", "/sys/block/", str2, "/device/model");
FILL_UINT_ARR(str1,
((0 != total) ? ((used * 100) / total) : 0));
}
-
-
-#if WITH_DRIVETEMP == 1
-/*
- * The data that we parse:
- * |/dev/sda|Corsair Force GT|24|C| */
-static size_t
-read_temp_data_cb(char *data, size_t size, size_t nmemb, char *str1) {
- static uint8_t one_run = 0, cols = 0;
- char *ptr = data;
- size_t sz = size * nmemb, x = 0;
-
- if (0 == one_run) {
- for (; *ptr; ptr++, x++) {
- if ((x+4) < sz) {
-
- if ('|' == *ptr) {
- ++cols;
- if (('C' == *(ptr+3) || 'C' == *(ptr+4)) && 3 == cols) {
- if (0 != (isdigit((unsigned char) *(ptr+1)))) {
- *str1++ = *(ptr+1);
- if (0 != (isdigit((unsigned char) *(ptr+2)))) {
- *str1++ = *(ptr+2);
- }
- }
- *str1 = '\0';
- break;
- }
- }
-
- }
- }
-
- one_run = 1;
- if ('\0' != *str1) {
- *str1++ = '\0';
- }
- }
-
- return sz;
-}
-
-
-/* Most of the time it takes 32 bytes to complete,
- * except sometimes the connection gets terminated
- * when only 31 bytes was received, so we dont check
- * the curl_easy_perform return value for that purpose.
- * Due to that, the call back function is called twice to
- * finish the left 1 byte, but we already have parsed the
- * drive temperature.
-*/
-void
-get_drivetemp(char *str1) {
- const char *da_url = "http://127.0.0.1:" DRIVE_PORT;
- CURL *curl = NULL;
-
- FILL_STR_ARR(1, str1, "0");
- curl_global_init(CURL_GLOBAL_ALL);
-
- if (NULL == (curl = curl_easy_init())) {
- goto error;
- }
-
- curl_easy_setopt(curl, CURLOPT_URL, da_url);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, read_temp_data_cb);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, str1);
-
- curl_easy_perform(curl);
-
-error:
- if (NULL != curl) {
- curl_easy_cleanup(curl);
- }
- curl_global_cleanup();
- return;
-}
-#endif /* WITH_DRIVETEMP */
#include "prototypes/net.h"
#include "prototypes/options.h"
#include "prototypes/weather.h"
+#include "prototypes/smart.h"
/* Because we ran out of a-z A-Z options,
* only long ones will be supported from now on.
{ .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 = "drivetemp", .key = DRIVETEMP, .doc = "Read the drive temperature from S.M.A.R.T" },
{ .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 = "statio", .key = 'S', .arg = "sda", .doc = "Read and written MBs to the drive so far." },
-#if WITH_SMARTEMP == 1
- { .name = "drivetemp", .key = DRIVETEMP, .doc = "Read the drive temperature from S.M.A.R.T" },
-#endif /* WITH_SMARTEMP */
-
#if WITH_WEATHER == 1
{ .name = "weather", .key = 'q', .doc = "The temperature outside." },
#endif /* WITH_WEATHER */
{ .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." },
{ .name = "wifiname", .key = 'h', .arg = "eth0", .doc = "The name of currently connected wireless/wifi network." },
-
-#if WITH_DRIVETEMP == 1
- { .name = "drivetemp", .key = DRIVETEMP, .doc = "Read the drive temperature from S.M.A.R.T" },
-#endif /* WITH_DRIVETEMP */
-
#endif /* __linux__ */
#if defined(__FreeBSD__) || defined(__OpenBSD__)
NEW_ARG_LABEL('S', char statio[VLA], statio, FMT_STATIO, STATIO_STR);
-
-#if WITH_SMARTEMP == 1
NEW_LABEL(DRIVETEMP, char drivetemp[VLA], drivetemp, FMT_TEMP);
-#endif /* WITH_SMARTEMP */
#if WITH_WEATHER == 1
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);
-
-#if WITH_DRIVETEMP == 1
- NEW_LABEL(DRIVETEMP, char drivetemp[VLA], drivetemp, FMT_TEMP);
-#endif /* WITH_DRIVETEMP */
-
#endif /* __linux__ */
void get_loadavg(char *);
#endif
-#if WITH_SMARTEMP == 1
-void get_drivetemp(char *);
-#endif /* WITH_SMARTEMP */
-
#endif /* COMMON_H_ */
void match_feature(char *, uint8_t num);
#endif /* HAVE_SENSORS_SENSORS_H */
-#if WITH_DRIVETEMP == 1
-void get_drivetemp(char *);
-#endif /* WITH_DRIVETEMP */
-
#endif /* __linux__ */
--- /dev/null
+/*
+ 10/23/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 SMART_H_
+#define SMART_H_
+
+void get_drivetemp(char *);
+
+#endif /* SMART_H_ */
--- /dev/null
+/*
+ 10/23/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(__linux__) && WITH_DRIVETEMP == 1
+#include <ctype.h>
+#include <curl/curl.h>
+#endif /* __linux__ && WITH_DRIVETEMP */
+
+#include "include/headers.h"
+#include "prototypes/smart.h"
+
+#if defined(__linux__) && WITH_DRIVETEMP == 1
+static size_t read_temp_data_cb(char *, size_t size, size_t nmemb, char *);
+
+/*
+ * The data that we parse:
+ * |/dev/sda|Corsair Force GT|24|C| */
+static size_t
+read_temp_data_cb(char *data, size_t size, size_t nmemb, char *str1) {
+ static uint8_t one_run = 0, cols = 0;
+ char *ptr = data;
+ size_t sz = size * nmemb, x = 0;
+
+ if (0 == one_run) {
+ for (; *ptr; ptr++, x++) {
+ if ((x+4) < sz) {
+
+ if ('|' == *ptr) {
+ ++cols;
+ if (('C' == *(ptr+3) || 'C' == *(ptr+4)) && 3 == cols) {
+ if (0 != (isdigit((unsigned char) *(ptr+1)))) {
+ *str1++ = *(ptr+1);
+ if (0 != (isdigit((unsigned char) *(ptr+2)))) {
+ *str1++ = *(ptr+2);
+ }
+ }
+ *str1 = '\0';
+ break;
+ }
+ }
+
+ }
+ }
+
+ one_run = 1;
+ if ('\0' != *str1) {
+ *str1++ = '\0';
+ }
+ }
+
+ return sz;
+}
+
+
+/* Most of the time it takes 32 bytes to complete,
+ * except sometimes the connection gets terminated
+ * when only 31 bytes was received, so we dont check
+ * the curl_easy_perform return value for that purpose.
+ * Due to that, the call back function is called twice to
+ * finish the left 1 byte, but we already have parsed the
+ * drive temperature.
+*/
+void
+get_drivetemp(char *str1) {
+ const char *da_url = "http://127.0.0.1:" DRIVE_PORT;
+ CURL *curl = NULL;
+
+ FILL_STR_ARR(1, str1, "0");
+ curl_global_init(CURL_GLOBAL_ALL);
+
+ if (NULL == (curl = curl_easy_init())) {
+ goto error;
+ }
+
+ curl_easy_setopt(curl, CURLOPT_URL, da_url);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, read_temp_data_cb);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, str1);
+
+ curl_easy_perform(curl);
+
+error:
+ if (NULL != curl) {
+ curl_easy_cleanup(curl);
+ }
+ curl_global_cleanup();
+ return;
+}
+
+#else
+
+void
+get_drivetemp(char *str1) {
+ FILE *fp = NULL;
+ uint_fast16_t temp = 0;
+ const char *pinkytemp = "/tmp/pinkytemp";
+
+ FILL_STR_ARR(1, str1, "0");
+
+ if (NULL == (fp = fopen(pinkytemp, "r"))) {
+ return;
+ }
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+ CHECK_FSCANF(fp, SCAN_UFINT, &temp);
+#pragma GCC diagnostic pop
+
+ CLOSE_X(fp);
+
+ FILL_ARR(str1, UFINT, temp);
+}
+#endif /* __linux__ && WITH_DRIVETEMP */