cat /sys/class/power_supply/BAT0/capacity - Shows your current battery percentage
cat /sys/class/net/w*/operstate - Shows if your wifi is connected (shows up if connected and down when not)
cat /sys/class/net/e*/operstate - Shows if your ethernet is connected (shows up if connected and down when not)
These are actual files in the linux system that you can open with a file manager and see the output !
There are many more like these in the
/sys/class directory. My first reaction when i knew about this was like “Why the hell haven’t i heard about it before ?”. This tip may be useful to general users, but for people who like to do scripting, this can be gold.
Does anyone know where to get more information about the
sys/class directory and what all the outputs mean in different cases ?
NOTE: i’m not a linux expert or a professional programmer, but i’m interested in them and learns what i can from online. So i prefer simple solutions that can be easily understood.
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.