From: a Date: Sun, 23 Oct 2016 00:25:47 +0000 (+0200) Subject: Reorganize X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ffb8a68cb68d95064990d2e09e29d914347ca3d6;p=pinky-bar%2Fpinky-bar.git Reorganize --- diff --git a/.gitignore b/.gitignore index bdb32a9..c1642d4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,6 @@ src/pinky_curses !extra/FreeBSD/Makefile -!extra/_pinkybar -!extra/man_template.pdc +!extra/zsh/_pinkybar +!doc/man_template.pdc !extra/Gentoo/app-admin/pinky/* diff --git a/README.md b/README.md index 175c117..1908027 100644 --- a/README.md +++ b/README.md @@ -192,27 +192,14 @@ 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 & -``` +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 @@ -224,18 +211,7 @@ 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/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 @@ -269,8 +245,7 @@ make 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 @@ -305,128 +280,7 @@ make all ncurses 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. @@ -507,69 +361,7 @@ After editing the wrong prototype I managed to stumbled upon a bug in OpenBSD's **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 -#include -#include - -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 @@ -667,52 +459,13 @@ sudo hddtemp -d /dev/sda 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 -#include -#include - -#include - -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: @@ -721,22 +474,7 @@ 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: @@ -785,49 +523,7 @@ The "soundcloud" alternative that is supported in cmus and your mpd client will 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. diff --git a/bootstrap b/bootstrap index 07d2be4..0b05384 100644 --- a/bootstrap +++ b/bootstrap @@ -148,7 +148,7 @@ _gen_files() { main_makefile=(' SUBDIRS = src - dist_man_MANS = extra/pinkybar.1 + dist_man_MANS = doc/pinkybar.1 # To satisfy make dist EXTRA_DIST = \ @@ -157,7 +157,7 @@ _gen_files() { README.md \ .gitignore \ m4 \ - xbm_icons \ + doc \ extra # uses tabs @@ -175,6 +175,7 @@ ncurses: 'options.c' 'net.c' 'weather.c' + 'smart.c' 'prototypes/cpu.h' 'prototypes/common.h' @@ -183,6 +184,7 @@ ncurses: 'prototypes/functions.h' 'prototypes/options.h' 'prototypes/weather.h' + 'prototypes/smart.h' 'include/headers.h' 'include/options_constants.h' diff --git a/extra/README.md b/doc/README.md similarity index 71% rename from extra/README.md rename to doc/README.md index fab8915..ffb8f07 100644 --- a/extra/README.md +++ b/doc/README.md @@ -1,7 +1,3 @@ -\_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 diff --git a/extra/man_template.pdc b/doc/man_template.pdc similarity index 95% rename from extra/man_template.pdc rename to doc/man_template.pdc index 02737c5..92578db 100644 --- a/extra/man_template.pdc +++ b/doc/man_template.pdc @@ -1,6 +1,6 @@ % 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. diff --git a/extra/pinkybar.1 b/doc/pinkybar.1 similarity index 70% rename from extra/pinkybar.1 rename to doc/pinkybar.1 index 8b830f9..a824b05 100644 --- a/extra/pinkybar.1 +++ b/doc/pinkybar.1 @@ -1,5 +1,5 @@ .\"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 @@ -784,32 +784,15 @@ make\ install \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 @@ -822,22 +805,8 @@ make\ install \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 @@ -882,8 +851,8 @@ make\ install \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 @@ -921,134 +890,8 @@ make\ install \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. @@ -1173,94 +1016,9 @@ OpenBSD's own libc. \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\ -#include\ -#include\ - -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: @@ -1384,46 +1142,8 @@ instant temperature report back to you. 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\ -#include\ -#include\ - -#include\ - -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 @@ -1431,8 +1151,6 @@ To read the drive temperature from S.M.A.R.T \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 @@ -1443,25 +1161,8 @@ frost\ ALL=NOPASSWD:/usr/sbin/smartctl \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 @@ -1526,56 +1227,8 @@ interested to listen. 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 diff --git a/extra/misc/.Xresources b/extra/misc/.Xresources new file mode 100644 index 0000000..a168ec5 --- /dev/null +++ b/extra/misc/.Xresources @@ -0,0 +1,113 @@ +! 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 diff --git a/extra/misc/openbsd_bugs.md b/extra/misc/openbsd_bugs.md new file mode 100644 index 0000000..3640114 --- /dev/null +++ b/extra/misc/openbsd_bugs.md @@ -0,0 +1,60 @@ +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 +#include +#include + +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); +``` diff --git a/extra/misc/skdump.c b/extra/misc/skdump.c new file mode 100644 index 0000000..eed1762 --- /dev/null +++ b/extra/misc/skdump.c @@ -0,0 +1,38 @@ +/* + * Sample program to demonstate the usage of libatasmart +*/ + +#include +#include +#include + +#include + +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; +} diff --git a/extra/mpd/README.md b/extra/mpd/README.md new file mode 100644 index 0000000..e8453db --- /dev/null +++ b/extra/mpd/README.md @@ -0,0 +1 @@ +\*BSD users should add the "musicpd" daemon user on their own diff --git a/extra/mpd/freebsd.conf b/extra/mpd/freebsd.conf new file mode 100644 index 0000000..5aa9bbf --- /dev/null +++ b/extra/mpd/freebsd.conf @@ -0,0 +1,17 @@ +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" diff --git a/extra/mpd/linux.conf b/extra/mpd/linux.conf new file mode 100644 index 0000000..f6a7500 --- /dev/null +++ b/extra/mpd/linux.conf @@ -0,0 +1,17 @@ +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" diff --git a/extra/mpd/openbsd.conf b/extra/mpd/openbsd.conf new file mode 100644 index 0000000..da54218 --- /dev/null +++ b/extra/mpd/openbsd.conf @@ -0,0 +1,17 @@ +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" diff --git a/extra/scripts/drive-temperature.sh b/extra/scripts/drive-temperature.sh new file mode 100644 index 0000000..1433370 --- /dev/null +++ b/extra/scripts/drive-temperature.sh @@ -0,0 +1,35 @@ +#!/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 & diff --git a/extra/scripts/dwm.sh b/extra/scripts/dwm.sh new file mode 100644 index 0000000..b7740e5 --- /dev/null +++ b/extra/scripts/dwm.sh @@ -0,0 +1,24 @@ +#!/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 & diff --git a/extra/scripts/pinky-curses.sh b/extra/scripts/pinky-curses.sh new file mode 100644 index 0000000..f59b96b --- /dev/null +++ b/extra/scripts/pinky-curses.sh @@ -0,0 +1,27 @@ +#!/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 +} diff --git a/extra/scripts/xmonad.sh b/extra/scripts/xmonad.sh new file mode 100644 index 0000000..efd5b3f --- /dev/null +++ b/extra/scripts/xmonad.sh @@ -0,0 +1,25 @@ +#!/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-*-*-*-*-*-*-*' & diff --git a/xbm_icons/arch.xbm b/extra/xbm_icons/arch.xbm similarity index 100% rename from xbm_icons/arch.xbm rename to extra/xbm_icons/arch.xbm diff --git a/xbm_icons/bat.xbm b/extra/xbm_icons/bat.xbm similarity index 100% rename from xbm_icons/bat.xbm rename to extra/xbm_icons/bat.xbm diff --git a/xbm_icons/clock.xbm b/extra/xbm_icons/clock.xbm similarity index 100% rename from xbm_icons/clock.xbm rename to extra/xbm_icons/clock.xbm diff --git a/xbm_icons/cpu.xbm b/extra/xbm_icons/cpu.xbm similarity index 100% rename from xbm_icons/cpu.xbm rename to extra/xbm_icons/cpu.xbm diff --git a/xbm_icons/diskette.xbm b/extra/xbm_icons/diskette.xbm similarity index 100% rename from xbm_icons/diskette.xbm rename to extra/xbm_icons/diskette.xbm diff --git a/xbm_icons/fan.xbm b/extra/xbm_icons/fan.xbm similarity index 100% rename from xbm_icons/fan.xbm rename to extra/xbm_icons/fan.xbm diff --git a/xbm_icons/fox.xbm b/extra/xbm_icons/fox.xbm similarity index 100% rename from xbm_icons/fox.xbm rename to extra/xbm_icons/fox.xbm diff --git a/xbm_icons/mem.xbm b/extra/xbm_icons/mem.xbm similarity index 100% rename from xbm_icons/mem.xbm rename to extra/xbm_icons/mem.xbm diff --git a/xbm_icons/mobo.xbm b/extra/xbm_icons/mobo.xbm similarity index 100% rename from xbm_icons/mobo.xbm rename to extra/xbm_icons/mobo.xbm diff --git a/xbm_icons/mpd.xbm b/extra/xbm_icons/mpd.xbm similarity index 100% rename from xbm_icons/mpd.xbm rename to extra/xbm_icons/mpd.xbm diff --git a/xbm_icons/net.xbm b/extra/xbm_icons/net.xbm similarity index 100% rename from xbm_icons/net.xbm rename to extra/xbm_icons/net.xbm diff --git a/xbm_icons/sm4tik-icon-pack.tar.bz2 b/extra/xbm_icons/sm4tik-icon-pack.tar.bz2 similarity index 100% rename from xbm_icons/sm4tik-icon-pack.tar.bz2 rename to extra/xbm_icons/sm4tik-icon-pack.tar.bz2 diff --git a/xbm_icons/statio.xbm b/extra/xbm_icons/statio.xbm similarity index 100% rename from xbm_icons/statio.xbm rename to extra/xbm_icons/statio.xbm diff --git a/xbm_icons/temp.xbm b/extra/xbm_icons/temp.xbm similarity index 100% rename from xbm_icons/temp.xbm rename to extra/xbm_icons/temp.xbm diff --git a/xbm_icons/uptime.xbm b/extra/xbm_icons/uptime.xbm similarity index 100% rename from xbm_icons/uptime.xbm rename to extra/xbm_icons/uptime.xbm diff --git a/xbm_icons/vol.xbm b/extra/xbm_icons/vol.xbm similarity index 100% rename from xbm_icons/vol.xbm rename to extra/xbm_icons/vol.xbm diff --git a/xbm_icons/voltage.xbm b/extra/xbm_icons/voltage.xbm similarity index 100% rename from xbm_icons/voltage.xbm rename to extra/xbm_icons/voltage.xbm diff --git a/extra/_pinkybar b/extra/zsh/_pinkybar similarity index 100% rename from extra/_pinkybar rename to extra/zsh/_pinkybar diff --git a/m4/sensors.m4 b/m4/sensors.m4 index 3ee4634..d7be9aa 100644 --- a/m4/sensors.m4 +++ b/m4/sensors.m4 @@ -23,7 +23,6 @@ dnl the variable 'SENSORS_LIBS' if the user enabled dnl the --with-sensors switch AC_DEFUN([TEST_SENSORS],[ SENSORS_LIBS="" - WITH_SMARTEMP=0 AC_ARG_WITH([sensors], AS_HELP_STRING([--with-sensors], @@ -32,13 +31,6 @@ AC_DEFUN([TEST_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], [ @@ -98,13 +90,7 @@ AC_DEFUN([TEST_SENSORS],[ ],[ ]) - 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"], [ diff --git a/m4/weather.m4 b/m4/weather.m4 index 4501fd1..a365c5f 100644 --- a/m4/weather.m4 +++ b/m4/weather.m4 @@ -43,6 +43,13 @@ AC_DEFUN([TEST_WEATHER],[ [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]) diff --git a/src/common.c b/src/common.c index add1935..ac65324 100644 --- a/src/common.c +++ b/src/common.c @@ -472,23 +472,3 @@ split_n_index(char *str1) { } *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 */ diff --git a/src/linux_functions.c b/src/linux_functions.c index a216da5..579416c 100644 --- a/src/linux_functions.c +++ b/src/linux_functions.c @@ -33,21 +33,12 @@ #include -#if WITH_DRIVETEMP == 1 -#include -#include -#endif /* WITH_DRIVETEMP */ - #if defined(HAVE_SENSORS_SENSORS_H) #include #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; @@ -90,7 +81,7 @@ get_ram(char *str1, uint8_t num) { 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"); @@ -379,81 +370,3 @@ get_battery(char *str1) { 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 */ diff --git a/src/options.c b/src/options.c index f477001..849e9a7 100644 --- a/src/options.c +++ b/src/options.c @@ -27,6 +27,7 @@ #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. @@ -60,6 +61,7 @@ static const struct argp_option options[] = { { .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." }, @@ -87,10 +89,6 @@ static const struct argp_option options[] = { { .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 */ @@ -117,11 +115,6 @@ static const struct argp_option options[] = { { .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__) @@ -227,10 +220,7 @@ parse_opt(int key, char *arg, struct argp_state *state) { 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 @@ -280,11 +270,6 @@ parse_opt(int key, char *arg, struct argp_state *state) { 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__ */ diff --git a/src/prototypes/common.h b/src/prototypes/common.h index c7a53f0..dd2addf 100644 --- a/src/prototypes/common.h +++ b/src/prototypes/common.h @@ -53,8 +53,4 @@ void get_dvd(char *); void get_loadavg(char *); #endif -#if WITH_SMARTEMP == 1 -void get_drivetemp(char *); -#endif /* WITH_SMARTEMP */ - #endif /* COMMON_H_ */ diff --git a/src/prototypes/functions.h b/src/prototypes/functions.h index 0e30ec5..addf303 100644 --- a/src/prototypes/functions.h +++ b/src/prototypes/functions.h @@ -37,10 +37,6 @@ void get_fans(char *); 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__ */ diff --git a/src/prototypes/smart.h b/src/prototypes/smart.h new file mode 100644 index 0000000..62cb21b --- /dev/null +++ b/src/prototypes/smart.h @@ -0,0 +1,25 @@ +/* + 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_ */ diff --git a/src/smart.c b/src/smart.c new file mode 100644 index 0000000..d80164d --- /dev/null +++ b/src/smart.c @@ -0,0 +1,131 @@ +/* + 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 +#include +#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 */