| -O | --driveavail| The available drive storage |
| -g | --battery | The remaining battery charge |
| -F | --drivemodel| The vendor name of your drive [argument - sda] |
+| -z | --dvdstr | The vendor and model name of your cdrom/dvdrom |
+| -S | --statio | Read and written MBs to the drive so far [argument - sda] |
| -p | --packages | The number of installed packages |
| -P | --kernsys | The kernel name |
| -q | --kernode | The network node hostname |
| -h | --nicdrv | The NIC driver [argument - eth0] |
| -H | --nicver | The NIC version [argument - eth0] |
| -j | --nicfw | The NIC firmware [argument - eth0] |
-| -S | --statio | Read and written MBs to the drive so far [argument - sda] |
The following options are available only in Linux: `-FhHGe`.
| --with-oss | --without-oss | To get the sound volume level in FreeBSD. |
| --with-net | --without-net | Enable the internet related options. |
| --with-pci | --without-pci | To get the NIC vendor and model |
+| --with-dvd | --without-dvd | To get the cdrom/dvdrom vendor and model |
| --with-colours | --without-colours | Colorize the output data. |
| icons=/tmp | | Use xbm icons that can be used by dzen2 for example. Discarded when **--with-x11** is used |
| --with-mpd | --without-mpd | To see the currently played song name (if any). |
By default, if **no** options are passed, the program will be compiled with/without:
```bash
---without-alsa --without-x11 --without-mpd --with-colours --with-net --with-pci
+--without-alsa --without-x11 --without-mpd --with-colours --with-net --with-pci --without-dvd
```
---
* alsa-utils
* alsa-lib
-Then pass **--with-alsa** to configure. FreeBSD users can use the baked OSS instead, pass **--without-alsa --with-oss** instead.
+Then pass **--with-alsa** to configure. FreeBSD users can use the baked OSS instead, pass **--without-alsa --with-oss** to configure instead.
+
+To get the vendor and model name of your cdrom/dvdrom/blu-ray:
+
+* libcdio
+* libcddb
+
+In linux **--without-dvd** will still compile the program with dvd support. Except it will be limited only to dvd support, it will try to parse the sr0 vendor and model name detected by the kernel.
To see the currently played song name:
TEST_X11
TEST_ALSA
TEST_MPD
+ TEST_DVD
TEST_TYPEZ
TEST_CFLAGZ
bin_PROGRAMS = '${progName}'
- '${progName}'_LDADD = $(X_LIBS) $(ALSA_LIBS) $(MPD_LIBS) $(PCI_LIBS) '${bsdLibs}'
+ '${progName}'_LDADD = $(X_LIBS) $(ALSA_LIBS) $(MPD_LIBS) $(PCI_LIBS) $(DVD_LIBS) '${bsdLibs}'
'${progName}'_SOURCES = '${src_files[@]}'
--- /dev/null
+dnl Copyright 08/23/2016
+dnl Aaron Caffrey https://github.com/wifiextender
+
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+dnl MA 02110-1301, USA.
+
+
+dnl TEST_DVD() function in configure.ac
+dnl
+dnl Substitute the linker flags -lcdio to the
+dnl the variable 'DVD_LIBS' if the user enabled
+dnl the --with-dvd switch
+AC_DEFUN([TEST_DVD],[
+ DVD_LIBS=""
+
+ AC_ARG_WITH([dvd],
+ AS_HELP_STRING([--with-dvd],
+ [dvd linker flag to show the vendor and model name of your cd/dvdrom]),
+ [],
+ [with_dvd=no]
+ )
+
+ AS_IF([test "x$with_dvd" = "xyes"], [
+ AC_CHECK_HEADERS([cdio/cdio.h], [
+ DVD_LIBS="-lcdio"
+ ],[
+ ERR_MUST_INSTALL([libcdio])
+ ])
+
+ AC_CHECK_HEADERS([ \
+ cdio/cdio.h \
+ cdio/mmc.h \
+ ], [
+ DVD_LIBS="-lcdio"
+ ],[
+ ERR_MUST_INSTALL([libcdio])
+ ])
+
+ m4_foreach([LiB], [
+ cdio_open ,
+ mmc_get_hwinfo ,
+ cdio_destroy
+ ],[
+ AC_CHECK_LIB(cdio,LiB,[],[
+ ERR([Missing core cdio function.])
+ ])
+ ])
+ ])
+
+ AC_SUBST(DVD_LIBS)
+
+ AS_IF([test "x$with_dvd" = "xyes"], [
+ AC_LINK_IFELSE([
+ AC_LANG_SOURCE([[
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <cdio/cdio.h>
+ #include <cdio/mmc.h>
+ int main(void) {
+ CdIo_t *p_cdio = cdio_open(NULL, DRIVER_DEVICE);
+ cdio_hwinfo_t hwinfo;
+ if (NULL == p_cdio) {
+ return 0;
+ }
+ if (mmc_get_hwinfo(p_cdio, &hwinfo)) {
+ printf("%s %s\n", hwinfo.psz_vendor, hwinfo.psz_model);
+ }
+ if (NULL != p_cdio) {
+ cdio_destroy(p_cdio);
+ }
+ return 0;
+ }
+ ]])
+ ],[],[
+ LINK_FAILED([cdio])
+ ]
+ )
+ ])
+
+])
#include "include/freebzd.h"
#endif /* __FreeBSD__ */
+#if defined(HAVE_CDIO_CDIO_H)
+#include <cdio/cdio.h>
+#include <cdio/mmc.h>
+#endif /* HAVE_CDIO_CDIO_H */
+
+
#if defined(__linux__)
static uint_fast16_t glob_packages(const char *);
#endif /* __linux__ */
FILL_STR_ARR(1, str1, (y != x ? buffer : NOT_FOUND));
}
}
+
+
+#if defined(HAVE_CDIO_CDIO_H)
+/*
+ CdIo_t *p_cdio = NULL;
+ cdio_hwinfo_t hwinfo;
+ driver_id_t driver_id = DRIVER_DEVICE;
+ char **device_list = cdio_get_devices_ret(&driver_id);
+ char **d = device_list;
+
+ if (NULL != d) {
+ for (; NULL != *d; d++) {
+ p_cdio = cdio_open(NULL, driver_id);
+ if (mmc_get_hwinfo(p_cdio, &hwinfo)) {
+ printf("%s %s\n", hwinfo.psz_vendor, hwinfo.psz_model);
+ }
+ if (NULL != p_cdio) {
+ cdio_destroy(p_cdio);
+ }
+ }
+ }
+ if (NULL != device_list) {
+ cdio_free_device_list(device_list);
+ }
+*/
+void
+get_dvd(char *str1) {
+ CdIo_t *p_cdio = cdio_open(NULL, DRIVER_DEVICE);
+ cdio_hwinfo_t hwinfo;
+
+ FILL_STR_ARR(1, str1, "Null");
+ if (NULL == p_cdio) {
+ FUNC_FAILED("cdio_open()");
+ }
+ if (mmc_get_hwinfo(p_cdio, &hwinfo)) {
+ FILL_STR_ARR(2, str1, hwinfo.psz_vendor, hwinfo.psz_model);
+ }
+ if (NULL != p_cdio) {
+ cdio_destroy(p_cdio);
+ }
+}
+#else
+
+#if defined(__linux__)
+void
+get_dvd(char *str1) {
+ FILE *fp;
+ char vendor[100], model[100];
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+ OPEN_X(fp, DVD_VEND, "%s", vendor);
+#pragma GCC diagnostic pop
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+ OPEN_X(fp, DVD_MODEL, "%s", model);
+#pragma GCC diagnostic pop
+
+ FILL_STR_ARR(2, str1, vendor, model);
+}
+#endif /* __linux__ */
+
+#endif /* HAVE_CDIO_CDIO_H */
#define USINT "%"PRIu8
#define SCAN_UFINT "%"SCNuFAST16
#define SCAN_ULINT "%"SCNuLEAST32
-#define SCAN_UINTX "%"PRIxMAX
+#define SCAN_UINTX "%"PRIxMAX /* hex */
/* stay away from va_list */
#define FILL_ARR(x, z, ...) (snprintf(x, VLA, z, __VA_ARGS__))
#define NIC_VEND(x, z) (NIC_NUM(x, z, "vendor"))
#define NIC_MODEL(x, z) (NIC_NUM(x, z, "device"))
+/* The cdrom/dvdrom vendor and model */
+#define DVD_DIR(x) ("/sys/class/block/sr0/device/"x)
+#define DVD_VEND DVD_DIR("vendor")
+#define DVD_MODEL DVD_DIR("model")
+
/* exit with error */
#define CANNOT_OPEN "Could not open"
#define ERR "Error:"
void
get_mobo(char *str1) {
FILE *fp;
- char vendor[VLA], name[VLA];
+ char vendor[100], name[100];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
{ .name = "drivetotal", .key = 'n', .doc = "The total drive storage." },
{ .name = "drivefree", .key = 'N', .doc = "The free drive storage." },
{ .name = "driveavail", .key = 'O', .doc = "The available drive storage." },
+ { .name = "dvdstr", .key = 'z', .doc = "The vendor and model name of your cdrom/dvdrom." },
{ .name = "battery", .key = 'g', .doc = "The remaining battery charge." },
{ .name = "drivemodel", .key = 'F', .arg = "sda", .doc = "The vendor name of your drive." },
+ { .name = "statio", .key = 'S', .arg = "sda", .doc = "Read and written MBs to the drive so far." },
{ .name = "packages", .key = 'p', .doc = "The number of installed packages." },
{ .name = "kernsys", .key = 'P', .doc = "The kernel name." },
{ .name = "kernode", .key = 'q', .doc = "The network node hostname." },
#else
{ .name = "nicgw", .key = 'j', .arg = "re0", .doc = "The NIC gateway address." },
#endif /* __linux__ */
- { .name = "statio", .key = 'S', .arg = "sda", .doc = "Read and written MBs to the drive so far." },
{ .doc = NULL }
};
struct arguments {
NEW_LABEL('T', char cpu_temp[VLA], cpu_temp, FMT_TEMP);
+#if defined(HAVE_CDIO_CDIO_H) || defined(__linux__)
+ NEW_LABEL('z', char dvd[VLA], dvd, FMT_KERN);
+#endif /* HAVE_CDIO_CDIO_H || __linux__ */
+
NEW_RAM_LABEL('J', char ram_total[VLA], ram_total, 1, FMT_RAM2, RAM_STR);
NEW_RAM_LABEL('K', char ram_free[VLA], ram_free, 2, FMT_RAM2, RAM_STR);
void set_status(const char *);
#endif
+#if defined(HAVE_CDIO_CDIO_H) || defined(__linux__)
+void get_dvd(char *);
+#endif /* HAVE_CDIO_CDIO_H || __linux__ */
+
#endif /* COMMON_H_ */