Commit Graph

402 Commits

Author SHA1 Message Date
Olivier Gayot
ca8c3e7337 No longer use a temporary buffer in the die() function
Before the following change

  f947d0a Breaks configfiles! Major refactoring of i3status, see below

The die(fmt, ...) function was outputting the reason to the status bar
in addition to stderr. For this reason, it was meaningful to create a
temporary string according to the format string and then passing it
around to the different functions.

Nowadays, we only display the error message to stderr so calling
fprintf(stderr, ...) is much simpler.

Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
2018-06-20 11:01:59 +02:00
Olivier Gayot
451ff9be0b Fix shown IP address belonging to wrong interface
The following commit:

  6a75ea9 Show IP address when address has a label

introduced a way to show the IP address of an interface when a label is
associated to the IP.

When a label is associated to an IP, the structure returned by
getifaddrs() has the label concatenated to the interface name in the
.ifa_name field as in the following example:

    struct ifaddrs ifaddr = {
       .ifa_name = "eth0:mylabel",
    };

As a consequence, using a strict comparison between the interface name
and the .ifa_name field yields a falsy result. However, checking if the
.ifa_name starts with the interface name (e.g. eth0) does not work
either because other network interfaces can have a name which starts
with eth0.

This commit solves the issue by stripping out the optional label from
the .ifa_name field before making a strict comparison with the interface
name.

Fix #283

Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
2018-06-11 22:06:57 +02:00
Olivier Gayot
99a6fb5e49 Simplify the algorithm used to determine the IP address
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
2018-06-04 19:59:09 +02:00
Ingo Bürk
b850f5852d
Merge pull request #270 from Stunkymonkey/mem-support
initial support of memory-usage for linux
2018-05-19 22:08:42 +02:00
eplanet
9a8106fab9 Fix MacOS build 2018-05-15 13:34:36 +02:00
Benedikt Heine
cba8f55938 Simplify the memory thresholds 2018-05-04 18:46:59 +02:00
Benedikt Heine
7839e93c9b Rename ram variables consistently 2018-05-04 18:46:38 +02:00
Felix Buehler
c55754542e Implement support for memory-usage on Linux 2018-04-11 22:36:41 +02:00
Ingo Bürk
82d25dc362
Merge pull request #275 from winks/patch-2
Fix NULL value on OpenBSD when there is no acpitz0
2018-04-08 15:53:19 +02:00
Florian Anderiasch
46b5c264d1 Fix NULL value on OpenBSD when there is no acpitz0
Using %degrees on OpenBSD resulted in garbage values if sysctl doesn't
know about any cpu temperature sensors.
2018-04-06 19:56:55 +02:00
Dan Robertson
6a75ea9aea
Show IP address when address has a label
If an address has been added with a label, ensure the correct address is
shown.
2018-03-29 10:46:36 +00:00
Øyvin Halfdan Thuv
3e1213123f Read multiple batteries on DragonFly BSD.
Using ACPI to read individual battery information instead of just
accumulations from sysctl.
2018-03-27 11:52:08 +02:00
Ingo Bürk
4345fa9d97
Merge branch 'master' into master 2018-03-27 09:26:55 +02:00
Ingo Bürk
3aec438a51
Merge pull request #243 from jasperla/fei_error
Remove overly aggressive #error
2018-03-27 09:07:53 +02:00
Carlin Bingham
5b416d4ac0 OpenBSD: fix volume display on some hardware
On some hardware the AUDIO_MIXER_READ ioctl requires the current number
of channels to be set, and the mute device found needs to be checked if
it belongs to the master output device.
2018-02-13 02:12:04 +13:00
Gerome Fournier
9212ee658b Make iface_type() work on FreeBSD 2018-02-07 11:26:34 +01:00
johcgt
d5c69a9d60 Treat zero battery capacity as "not available" (#259)
`print_battery_info` computes `batt_info.percentage_remaining` by
dividing batt_info.remaining by `full`. If `full` is `0` then the
battery remaining will be reported as "inf".

Before this, it tries to set `full` to either the design capacity or to
the last known good charge. It determines if these values are available
by checking whether their fields in `batt_info` are non-negative. As it
initialized `batt_info` with values of `-1`, a non-negative value
implies that something has provided a value.

`slurp_all_batteries` and `add_battery_info` however initialize these
fields to zero, so if these functions are called then
`batt_info.full_design` will always be used.

This means that on systems that don't provide a value for design
capacity the percentage remaining will be reported as "inf", unless the
user has set `last_full_capacity` to `true` in their `i3status.conf`.

This patch changes `print_battery_info` to expect values for the battery
capacity to be strictly greater than zero. This seems reasonable as a
battery with a capacity of zero isn't useful.

An alternative solution would be to change `slurp_all_batteries` and
`add_battery_info` to initialize `batt_info` with `-1`, as
`print_battery_info` does. This is less appealing as `add_battery_info`
is accumulating the values, so using `-1` would introduce off-by-one
errors without additional code to avoid them.
2018-01-28 15:37:51 +01:00
Emeric Planet
657c0498db Update comment as in #247 (#254) 2017-12-11 12:16:00 +01:00
Emeric Planet
53fb9b4f18 Add IPv6 address when IPv4 isn't available (#247) 2017-12-11 11:38:31 +01:00
eplanet
20a701bdf0 Call tzset at each time print 2017-12-09 15:48:18 +01:00
Jasper Lievisse Adriaanse
83d0b621c0 Remove overly aggressive #error
Change-Id: I8c20606d386d713cac51b620d1fcdb479a3622fe
2017-09-04 13:30:21 +02:00
kousu
62d0905c7f Be more cautious about handling invalid battery measurements. 2017-08-24 19:00:08 -04:00
Emeric Planet
ca9bee8b88 Use local timezone for battery %emptytime (#236) 2017-08-19 14:56:30 +02:00
Ingo Bürk
0e406a1f3b Merge pull request #219 from flammi/master
Add check for virtual ethernet devices
2017-04-16 07:43:30 +02:00
Emeric Planet
c7dea74751 Add battery capacity parsing (#216)
The Linux power supply class defines three entries to provide battery status.
One of them wasn't used: POWER_SUPPLY_CAPACITY.

https://www.kernel.org/doc/Documentation/power/power_supply_class.txt
2017-04-13 21:46:21 +02:00
Fabian Franzen
6a19709e65 Added braces
Added braces to the if-statement as requested.
2017-04-13 12:51:29 +02:00
Fabian Franzen
ad3fac03c3 Fix memory leak/Use BEGINS_WITH macro
The orignal proposed code had a memory leak when returning true.
Furthermore I included the handy BEGINS_WITH macro of i3 which makes the
code (IMHO) a lot more readable.
2017-04-12 13:11:34 +02:00
Fabian Franzen
f45581f8d8 Add check for virtual ethernet devices
The _first_ option for ethernet devices now uses the link in sysfs to determine
if it's a real device or just a virtual one (i.e veth** devices created by docker).
2017-04-12 03:46:04 +02:00
eplanet
94651257ce Multiple CPU support for cpu_usage (#209)
This change addresses the issue #199 asking for multiple CPU support. It
takes an arbitrary CPU number and outputs its usage using the same
arithmetics as for CPU aggregation. It currently doesn't support
FreeBSD.
2017-03-26 06:54:07 -04:00
Kenneth Lyons
8e12ad8308 disk: don't remove trailing slash if path is a single character 2017-03-10 11:24:56 -08:00
Ingo Bürk
09c758eed5 Merge pull request #208 from stapelberg/warning
remove useless checks (we use char, not unsigned char)
2017-03-08 22:26:33 +01:00
Michael Stapelberg
eee4ace092 remove useless checks (we use char, not unsigned char)
fixes compilation warnings
2017-03-08 19:24:09 +01:00
Michael Stapelberg
27952b11f7 disk: sanitize trailing slashes
fixes #200
2017-03-08 19:22:22 +01:00
Ingo Bürk
37e73e77b0 Merge pull request #202 from jasperla/openbsd_fdleak
Plug an fd leak in the OpenBSD-specific code for _first_
2017-02-07 20:47:06 +01:00
Jasper Lievisse Adriaanse
3c6d5ac3d7 Plug an fd leak in the OpenBSD-specific code for _first_ 2017-02-07 19:29:01 +01:00
Jasper Lievisse Adriaanse
9166765803 Suppress printing :00 seconds of remaining battery lifetime, as apm(4)'s
estimate only has a granularity of minutes.

From tb@openbsd.org
2017-02-07 19:25:03 +01:00
Baptiste Daroussin
93576bccc3 Fix the deciKelvin to Celsius conversion on FreeBSD (#195)
Change from ceiled value to floored value to be consistent with the
FreeBSD kernel

https://svnweb.freebsd.org/base?view=revision&revision=300421
2017-02-01 11:28:01 -08:00
Jasper Lievisse Adriaanse
e09186fa19 Make first_eth_interface() work on OpenBSD: (#197)
- use a define for loopback interface device
- use an approach similar to ifconfig(8) for determining device type
2017-01-31 23:28:38 -08:00
Jasper Lievisse Adriaanse
897d03ed5e Include sys/select.h on OpenBSD (#198)
Fixes a compilation error:
/usr/include/net80211/ieee80211_ioctl.h:339: warning: implicit declaration of function 'howmany'
/usr/include/net80211/ieee80211_ioctl.h:339: error: 'NBBY' undeclared here (not in a function)
/usr/include/net80211/ieee80211_ioctl.h:339: error: variably modified 'nr_rxmcs' at file scope
2017-01-31 23:26:13 -08:00
Mihai Coman
9375959b68 Add 'format_below_threshold' option for 'disk' module
Add 'format_above_threshold' option for 'cpu_temperature' module
Add 'format_above_threshold' option for 'cpu_usage' module
Add 'format_above_threshold' option for 'load' module
2016-11-15 01:09:05 +02:00
Jon Bernard
220b9e1565 Use blank padding for wireless quality (#166) (#167) 2016-11-12 06:39:41 -08:00
Björn Lindström
be87c5ac38 Setting of custom locale in tztime configuration. (#168)
To be able to show my birth country's time zone in that country's locale, and my local time in my current locale.
2016-10-24 08:43:04 +02:00
Stu Zhao
707ceffc8b Detect batteries using glob (#163) 2016-10-23 21:20:31 +02:00
Watcom
8d2ef5f99b pulse device may be specified by name (#126) (#162) 2016-09-14 09:26:45 +02:00
Tommie Gannert
dc072f9f53 Implement aggregates for batteries.
Using title number all, this enables aggregates. Note that FreeBSD and
OpenBSD previously only reported aggregates, so this is bringing Linux
and NetBSD that functionality.

Changes the default battery reporting to the aggregate since most
users probably don't care about individual batteries. For single-battery
systems there should be no change.

Fixes one obvious memory leak in NetBSD.
2016-08-28 14:29:08 +01:00
Tommie Gannert
ac8998ef03 Match trailing equal sign in slurp_battery_info.
Should make it more resilient to future ambiguities in uevent.
2016-08-22 21:18:31 +01:00
Cihangir Akturk
15de209cba Parse uevent file to detect network device type (#153)
Currently i3status differentiates wireless and wired devices based
on the existence of wireless directory inside the device's sysfs
directory. This approach seems to cause 3g modems to be incorrectly
identified as the first ethernet device.

This commit solves this problem by using DEVTYPE variable from
uevent file.

Signed-off-by: Cihangir Akturk <cakturk@gmail.com>
2016-08-22 10:23:59 -07:00
Michael Stapelberg
ef16acfca5 print_wireless_info: fix FTBFS on hurd and kfreebsd
Patch by Axel Beckert.
2016-08-22 08:49:19 +02:00
tnnn
a2fd4bd074 Added missing ampere to watt conversion for last full capacity. (#158)
Signed-off-by: Tomasz Nitecki <tnnn@tnnn.pl>
2016-08-21 13:11:19 -07:00
eplanet
fde5ebfa1e Print empty string for not mounted disks. (#148)
An empty string becomes the default value for format_not_mounted parameter
for any disk entry. This avoids printing erroneous values when a
filesystem is not mounted.
2016-08-16 00:29:08 -07:00
tommie
7ce0044a03 Move time and ratio computations out of slurp_battery_info. (#151)
This allows OSes that support reporting multiple batteries to simply
sum into full_design,full_last,remaining and let print_battery_info
make computations.
2016-08-14 23:52:20 -07:00
Tommie Gannert
d74bc90bfe Move full_design and full_last into struct battery_info.
This is in preparation for moving the ratio computation code out of
slurp_battery_info to support aggregating multiple batteries.
2016-08-14 20:44:54 +01:00
Tommie Gannert
9970af67e5 Also capture charge rate in NetBSD.
For time estimates when charging.
2016-08-14 20:44:54 +01:00
Tommie Gannert
eb0b6412af Fix warnings about using a char array index on NetBSD.
The isspace macro is just a table lookup.
2016-08-14 12:37:38 +01:00
Tommie Gannert
a937693cef Simplify string comparisons in slurp_battery_info for NetBSD.
Doing strlen(a) == strlen(b) && strncmp(a, b, N) seems to have no
benefits compared to just strcmp(a, b). The NetBSD cstring properties
come from the kernel, not the user.

The test for units did a prefix match, but that looked like a bug, the
unit is "Watt hour" in my Virtual box.
2016-08-14 12:20:43 +01:00
Tommie Gannert
7728cff370 Make print_disk_info, print_eth_info and print_wireless_info compile on NetBSD without warnings. 2016-08-14 11:52:27 +01:00
Tommie Gannert
185d70ecbb Remove warnings about unused variables in slurp_battery_info on OpenBSD. 2016-08-14 11:52:27 +01:00
Tommie Gannert
4189824ffb Define IW_ESSID_MAX_SIZE for OpenBSD.
Also fixes a signedness warning.
2016-08-14 11:52:27 +01:00
Tommie Gannert
77f097dcca Move OS-specific code to slurp_battery_info. 2016-08-03 23:27:04 +01:00
Tommie Gannert
a537d1503a Introduce a struct battery_info to carry information from data retrieval to the output formatter. 2016-08-03 23:27:04 +01:00
Tommie Gannert
0b16860145 Refactor common seconds_remaining code in print_battery_info. 2016-08-03 23:09:16 +01:00
Tommie Gannert
52f0dd6a36 Remove an END_COLOR in print_battery_info for OpenBSD.
This was probably a bug since it makes no sense to have here.
2016-08-03 23:09:15 +01:00
Tommie Gannert
6d3e9991de Move START_COLOR to after OS-specific code.
This uses the more direct tests of whether percentage_remaining and
seconds_remaining are available or not (rather than looking at
present_rate).
2016-08-03 23:09:02 +01:00
Tommie Gannert
47ec48b85d Remove consumptionbuf from print_battery_info. 2016-08-03 20:13:10 +01:00
Tommie Gannert
b890d2e416 Remove emptytimebuf from print_battery_info.
This changes the behavior for NetBSD: previously this time was not
shown while charging. On Linux it was treated as "full time". This
change makes all OSes behave the same.

OpenBSD and FreeBSD did not support emptytime previously.
2016-08-03 20:13:10 +01:00
Tommie Gannert
63724e2fa5 Remove remainingbuf from print_battery_info. 2016-08-03 08:24:24 +01:00
Tommie Gannert
0390dbf2e0 Remove percentagebuf from print_battery_info. 2016-08-01 00:34:31 +01:00
Tommie Gannert
88a0c6923c Remove statusbuf from print_battery_info. 2016-08-01 00:24:40 +01:00
Michael Stapelberg
8e852fa945 Merge pull request #139 from Gjum/wb-colored-cpu-usage
Add CPU usage color thresholds
2016-07-30 19:23:20 +02:00
Alexis Hildebrandt
0a2d4d8a04 Add ifdef to compile wireless_info on Mac (#127) 2016-05-13 09:50:09 +02:00
Watcom
4807be8b5f reconnect to PulseAudio if connection is lost (fixes #124) (#125) 2016-05-08 00:19:30 +02:00
Mark Schreiber
1e8dab273d Add CPU usage color thresholds
CPU usage had previously not supported the color option.  Add support
for a "degraded" state above which the degraded color is used, and a
higher "bad" state above which the "bad" color is used.  One possible
use for these might be indicating whether one or all cores are
saturated.

Unlike the color settings for other, these are set high enough to be
disabled by default.  This is done because i3status determines CPU
usage over only the last display interval, which means that, a user
with a low refresh rate might see frequent, potentially-annoying color
changes.
2016-04-13 09:11:32 -07:00
eoin
d59589bf9e Added status_unk to battery_info 2016-03-21 22:41:22 +00:00
eplanet
a8aa5d608c Adding glob check to cpu temperature fixes #55 2016-03-20 11:47:56 +01:00
Clayton Craft
430b053326 This removes the 'remaining' time when the battery is full, since the remaining time is always 00:00:00. When the battery is discharging, the remaining time will show up again if the user has set their format correctly. 2016-01-25 00:38:13 -08:00
Watcom Hecht
dd75c260f8 revert back to using nanosleep
Fixes #93
2016-01-12 11:46:42 -02:00
Michael Stapelberg
fad9c8237c Bugfix: check that format_not_mounted is not NULL before using it
This issue was introduced with commit 75a83574.

fixes #92
2016-01-12 09:50:44 +01:00
David
b54623a56d format detection: recognise swaybar 2015-12-27 15:59:32 +11:00
Kenneth Lyons
dcd0518e25 Added support for Pango markup. 2015-12-04 10:27:18 -08:00
Michael Stapelberg
876c1cef8d fix compilation on FreeBSD
fixes #83
2015-11-24 19:26:07 +01:00
Michael Stapelberg
3e14e6e5f3 first_eth_interface: ignore MAC addresses, look for IPv4/IPv6 addresses 2015-11-16 22:41:18 +01:00
Stefan Bader
9e6e0d4f8f Correctly calculate Wireless link quality
Wireless quality was stuck at 100% due to
a signed with unsigned integer division.
2015-10-12 20:46:22 +02:00
Jakub Klinkovský
611e863ace Volume percentage should be obtained by float division and rounded to int.
Fixes #75
2015-10-12 09:44:13 +02:00
Michael Stapelberg
1935110ef3 Merge pull request #71 from bsdjhb/freebsd_wifi_buildfix
Fix build under FreeBSD after recent changes for Linux.
2015-10-09 09:11:16 -07:00
John Baldwin
9ebde24df1 Fix build under FreeBSD after recent changes for Linux. 2015-10-08 13:20:02 -07:00
John Baldwin
5e33d9fe74 Properly detect the battery charging status under FreeBSD.
The hw.acpi.battery.state sysctl returns a bitmask of flags as
defined in <dev/acpica/acpiio.h>.  Use constants from this header
to examine the state and check for the charging flag to determine
if the battery is charging.
2015-10-08 13:15:38 -07:00
Brendan Van Hook
a13b2e7288 Added support for lemonbar 2015-10-04 14:52:32 -04:00
Michael Stapelberg
f3125fdfde document code origins
fixes #65
2015-09-25 11:40:07 +02:00
Michael Stapelberg
06a133135f Fix comparison between signed/unsigned warning for real 2015-09-25 11:05:51 +02:00
Michael Stapelberg
b8b07511b1 use proper unsigned type for ESSID length 2015-09-25 10:49:14 +02:00
Michael Stapelberg
45ccd84309 use nlmsg_data instead of the too-new genlmsg_hdr 2015-09-25 10:49:01 +02:00
Michael Stapelberg
e1203ca62a use NL80211_RATE_INFO_BITRATE (16-bit)
NL80211_RATE_INFO_BITRATE32 is not available widely enough yet (the libc
used by travis doesn’t have it yet, for example).
2015-09-25 10:42:30 +02:00
Michael Stapelberg
668bf2079f wireless (linux): switch from libiw to libnl
Based on http://cr.i3wm.org/patch/692/ by Alexander Monakov

fixes #32
fixes #52
2015-09-24 21:47:02 +02:00
Michael Stapelberg
fb57fca5c2 Merge pull request #59 from bsdjhb/freebsd_wifi
Fix various issues with wireless information under FreeBSD:
2015-09-16 14:06:48 +02:00
John Baldwin
85618dc8e8 Fix various issues with wireless information under FreeBSD:
- Instead of hoping that the currently associated AP will show up as
  the first AP in the list of scan results, fetch the BSSID of the
  currently associated AP and use that to fetch station info for the
  AP.  This provides more frequently updated signal strength
  information than scan results and reliably provides information when
  multiple APs are in range.
- Do not treat the RSSI value as a raw signal value in dBm.  Instead, use
  the same formula as ifconfig(8) to compute a signal value.
- Do not report the beacon interval value as a signal quality level.
2015-09-15 13:39:01 -07:00
John Baldwin
dee6d52720 Fix some issues with displaying Ethernet media status on recent FreeBSD kernels.
- Don't apply IFM_SUBTYPE to the raw subtype in the description table.
  IFM_SUBTYPE() requires a fully populated word and was truncating values
  in the table when comparing resulting in false matches (notably
  "10GBase-KX4" for the no media case) after recent changes to add extended
  Ethernet media states in FreeBSD.
- Explicitly check for IFM_ETHER.
- Use SIOCGIFXMEDIA when present to obtain extended media states on newer
  kernels.
- Explicitly handle "no carrier".
2015-09-15 10:48:16 -07:00
Dmitrij D. Czarkoff
9b238a8d65 Use "color_degraded" when interface has no IP
On laptops one may want to have all interfaces up in order to let network
prioritization manage switching between wired and wireless connection.  In such
cases lack of IP address is a useful hint about currently used interface, and
color-coding makes it stand out more.
2015-08-06 17:20:29 +02:00
Dmitrij D. Czarkoff
15f2279592 Use SndIO for volume module on OpenBSD
* add audio(4) code by Robert Nagy
 * disable PulseAudio

While at OpenBSD support, add "-pthread" to LIBS.
2015-08-01 17:35:09 +02:00
Alexis Hildebrandt
80e7b83d54 Add ifdef to compile print_disk_info on Mac 2015-07-06 15:48:39 +02:00
Alexis Hildebrandt
d1cec2632d Fix undeclared identifier thermal_zone error
when THERMAL_ZONE is not defined.
2015-07-06 15:47:44 +02:00
Viktor Stanchev
a2b8529043 add apostrophe to error message to fix grammar 2015-06-12 23:08:46 -04:00
Ingo Bürk
75a835742e Use format_not_mounted if the directory for a disk_info block does not exist.
This is useful for dynamically mounted devices like thumb drives that get mounted into a directory such as
'/media/$UID/$NAME'.

fixes #33
2015-05-29 08:43:29 +02:00
Michael Stapelberg
d1aa135d28 Clamp the percentage at 100% when last_full_capacity is enabled. 2015-05-20 19:17:23 +02:00
Nicholas Helke
d7f0d64c40 Changed battery info output to HH:MM for consistency accross all platforms 2015-05-05 10:51:57 +01:00
Watcom Hecht
f779da1a59 PulseAudio muted volume support (fixes #27) 2015-04-19 13:28:26 -03:00
Jasper Lievisse Adriaanse
e91891729e Use the maximum rssi, not the scaled percentage for the signal level.
This makes the value for %signal match ifconfig(8) in all cases.
2015-04-04 10:56:58 +02:00
Michael Stapelberg
9abe0a9d59 Merge pull request #7 from Watcom/master
PulseAudio support for volume input
2015-04-03 14:45:40 -07:00
Watcom Hecht
1710c206cf PulseAudio support for volume input 2015-04-03 17:57:40 -03:00
Michael Stapelberg
d00a0e087c Merge pull request #17 from chrko/format_down
Adding format_down option to path_exists and run_watch
2015-04-02 13:42:47 -07:00
Christian Kohlstedde
5c094a5493 Adding the option "format_down" to path_exists and run_watch.
This fixes #1.
2015-04-02 22:31:06 +02:00
Jasper Lievisse Adriaanse
ae50bbe257 sys/dkstat.h has been removed from OpenBSD and it's functionality actually lived/lives in sys/sched.h 2015-04-02 20:31:17 +02:00
Watcom Hecht
b12e11237b refactoring to avoid code duplication 2015-03-29 17:05:26 -03:00
Baptiste Daroussin
c9dc67e054 print_cpu_usage: Fix warnings on non linux
Move linux variable under LINUX boundaries
2015-03-25 08:19:13 +01:00
Baptiste Daroussin
0b882f36b5 print_eth_info: fix warnings on FreeBSD 2015-03-25 08:18:23 +01:00
Baptiste Daroussin
eaf5d6bf80 print_volume: don’t return, complete the buffer first
Follow the changed done for Linux on f0cd726b
2015-03-25 08:13:47 +01:00
Baptiste Daroussin
e9fc4c1c06 Fix build on FreeBSD 2015-03-25 08:03:23 +01:00
Ingo Bürk
0a84bcb74a Pass the "instance" JSON property key for tztime blocks
fixes #10
2015-03-23 21:42:52 +01:00
Michael Stapelberg
d74e904bf4 clang-format-3.5 -i **/*.[ch], update modeline
From here on, we’ll use clang-format to automatically format the source.

This has worked well in i3, so we are introducing it for i3status.
2015-03-16 10:01:07 +01:00
Christian Kohlstedde
562a879f7c removing Yoda-Style
adding some words in the manpage
2015-02-22 18:25:12 +01:00
Christian Kohlstedde
85bb373095 Adding optional configuration option to "print_disk_info". 2015-02-18 23:43:25 +01:00
Christian Kohlstedde
f7b25a15dd Excluding the code on BSD systems. 2015-02-18 22:11:57 +01:00
Christian Kohlstedde
014e66563f Make the code more readable. 2015-02-18 22:11:16 +01:00
Christian Kohlstedde
e70ea4247f Modify print_disk_info. Now there is no output if the path is no mountpoint. 2015-02-18 16:53:24 +01:00
Alexander Monakov
05273b03fd Avoid use of uninitialized variable in print_battery_info
The boolean flag 'watt_as_unit' may be used without being initialized if the
configured battery path does not contain expected statistics (for example if
it is misconfigured and points to AC adapter info or simply an unrelated file).

Even though it does not cause ill effects, it causes a warning (true positive)
when running i3status under Valgrind.  Initialize the variable to make code
well-defined.
2014-12-22 09:19:40 +01:00
Michael Stapelberg
b219f47f39 support the special interface name _first_ for ethernet/wireless
Since we have deterministic device names in Linux, these strings are a
much better default in the i3status config than "eth0" and "wlan0" (what
we used before).
2014-12-07 15:17:31 +01:00
Tuomas Tynkkynen
7bdfb5b72e i3status: Support %frequency for wireless interfaces
In many public WiFis, the 2.4 GHz wireless band is slow due to
congestion, while there is still plenty of bandwidth available on the
5 GHz area. So when debugging wireless issues it's convenient to have
i3status display the frequency of the access point that the interface is
connected to.

This patch adds support for the %frequency tag for wireless interfaces,
so for example:
    format_up = "WLAN: %essid - %quality / %frequency"
would result in:
    "WLAN: eduroam - 074% / 2.4 GHz"
2014-12-03 08:14:21 +01:00
Cyril Andreatta
8e22f3839d Created three individual Strings for each battery status (charging, dicharching, full)
Replaced hard coded status strings (CHR, BAT, FULL) in
print_battery_info.c with user defined strings. The new strings are
'status_chr', 'status_bat' and 'status_full' and can be set in i3status.conf.
e.g.
status_chr = " CHR"

If any of the new status strings is omitted the standard strings (CHR,
BAT, FULL) are used.
2014-10-07 18:52:01 +02:00
Michael Stapelberg
8a57208b1d Bugfix: fix wrong color tags with xmobar
fixes #1353
2014-08-26 20:54:04 +02:00
Klemen Košir
fcd95c2408 Fix battery indicator on systems without POWER_SUPPLY_VOLTAGE_NOW.
In my case, the voltage variable would stay initialized as -1,
which caused the calculation of battery charge percentage to be
incorrect (I would get the message that there is no battery present
or even -0% charge).

I have no idea how this would affect other systems, since I don't
have a chance to test this.
2014-08-25 19:36:02 +02:00
Robin Hahling
d73ca2fa82 Fix Dragonfly BSD CPU temperature gauge
This patch fixes CPU temperature gauge for DragonFly BSD.
Commit 0eeded8 assumed that fetching CPU temperature for DragonFly
BSD was similar to that of FreeBSD but this assumption is false.
2014-08-08 11:57:01 +02:00
Michael Stapelberg
2158128ea0 Use the absolute values for (dis)charging rates
Apparently some notebooks report a negative current, whereas most don’t.

fixes #1249
2014-05-31 14:01:18 +02:00
Michael Stapelberg
653505a3bb run_watch: check all matching pid files (until first valid one) (Thanks brotbart)
fixes #1245
2014-05-15 21:51:01 +02:00
Alexander Vasarab
b26b118d76 Fix NetBSD CPU temp gauge bug
This patch fixes a bug in which multiple (conflicting) CPU temps may be
included in the output for the "cpu temperature" module.

The bug is due to the way that the code parsed the envsys(4)-returned data,
and would manifest itself on x86-based NetBSD machines, since those use
cputemp(4) as well as acpitz(4), thereby creating multiple envsys(4) entries
with identical descriptions but which refer to different physical sensors.

Instead of matching the description attribute of each device returned by
envsys(4) against the target format, this patch throws away non-matching keys
in the first instruction inside the dict walk. This has the benefit of sparing
unnecessary CPU cycles, and preventing other sensors from being included
erroneously.

Additionally, the THERMAL_ZONE format is now joined with OpenBSD in that it
uses acpitz(4) explicitly. This is prefered since it is much older (dating
back to NetBSD 2.0), and does not exclude x86-based users (as with cputemp(4)).
2014-04-30 09:28:09 +02:00
Alexander Vasarab
628149b227 Implement battery functionality for NetBSD users
This patch takes a similar approach as the NetBSD CPU temperature
code in that it uses proplib(3) to walk dictionaries supplied by
envsys(4).

In addition to providing the basic functionality, it:

* Provides all existing format specifiers (%emptytime %consumption
  %status %percentage %remaining)
* Respects all existing config options (hide_seconds, low_threshold,
  integer_battery_capacity, last_full_capacity)
* Projects "time until full" when battery status is CS_CHARGING
2014-04-30 09:23:17 +02:00
Mats
4f7da73885 Unify use of string comparisons
* strncmp(s1, s2, strlen(s2)) → BEGINS_WITH(s1, s2)
* strncmp(s1, s2, strlen(s1)) → strcmp(s1, s2)
* Prefer case-insensitive comparison for options
2014-03-12 08:28:16 +01:00
Jasper Lievisse Adriaanse
52814295a0 For the %percentage display of batteries, drop the leading '0' for values < 10. 2014-03-12 08:27:00 +01:00
Mats
bc0bd8c9e0 disk: Colorize output when below given threshold
New disk module options:
* threshold_type: ^(percentage|[kmgt]?bytes)_(free|avail)$
* low_threshold: <double>

fixes #912
2014-03-09 22:57:19 +01:00
Marco Hunsicker
0c2b518b8a Typo in function name
Fixes the typo in print_seperator()
2014-03-01 22:35:37 +01:00
Marco Hunsicker
7b021d3eb2 i3status: Allow customization of module separator
This patch adds the ability to customize the separator that is placed
between modules.

Specifically this patch:

* adds the "separator" general directive
* moves the definition of the default separator for the different
  output formats (excluding color formatting) to src/i3status.c
* updates the SEC_CLOSE_MAP macro to disable the separator for the
  i3bar output format if the separator directive dictates so
* changes print_seperator() in src/output.c to take a separator
  parameter in order to disable the output of the separator if
  the separator is empty and to use the provided separator
  otherwise
* updates the manpage to explain the new directive
2014-03-01 10:21:11 +01:00
Marco Hunsicker
26faed4c2f i3status: Bugfix: Reading multiple temperature sensors not possible
This patch inlines the creation of the thermal zone string in order
to force computation on each invocation. This is necessary to be able
to read the values of several temperature sensors.
2014-02-26 22:32:32 +01:00
Iakov Davydov
c01a8110a4 Add hide_seconds option
fixes: #1134
2014-02-08 20:36:59 +01:00
Mats
596f2264f4 disk: Distinguish between IEC, SI and custom prefixes
* IEC: Ki, Mi, Gi, Ti (powers of 1024)
* SI: k, M, G, T (powers of 1000)
* custom: K, M, G, T (powers of 1024)
2013-12-10 21:18:14 +01:00
Kinware AB
717484184f Add support for path_exists directive. 2013-11-22 15:52:27 +01:00
Gereon Kremer
4bd0ba88c8 Added different format string for volume in case it is muted.
If the volume is muted, the volume level would simply be displayed as zero and the color changed to color_degraded.
This patch lets the user define a custom format string for when the volume is muted.
The default value is "♪: 0%" ("♪: %volume" being the usual format).
2013-11-18 22:31:42 +01:00
Michael Stapelberg
14b43bdec2 format detection: simplify code, handle "sh" processes in the hierarchy
i3 starts processes using /bin/sh now, not $SHELL. This increases the
likelihood with which we are started by dash, which tends to leave its
processes in the hierarchy, e.g.:

michael       1524  i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-s
michael       1525   \_ /bin/sh -c i3status
michael       1526       \_ i3status

This case is now handled correctly — when the parent is “sh”, the parent
of sh will be used instead.
2013-11-09 14:37:05 +01:00
Michael Stapelberg
31509b0d56 fix slurp(), it needs to read size-1 for the trailing NUL 2013-11-09 14:37:04 +01:00
Michael Stapelberg
ebfafc5dac print_cpu_temperature: fix memory leak (Thanks kuba) 2013-10-24 19:19:21 +02:00
Arnaud Degroote
c6e9fc84c6 Add support for cpu temperature on NetBSD (using envsys(4)) 2013-10-07 19:32:50 +02:00
Arnaud Degroote
32551729e8 Allow to print cpu usage on NetBSD 2013-10-07 19:31:01 +02:00
Arnaud Degroote
cf2fb61911 Allow to print eth information on NetBSD 2013-10-07 19:30:51 +02:00