-
Notifications
You must be signed in to change notification settings - Fork 485
Oneliners
- Boot Time
- Daemon Status
- Path Exists
- Disk Capacity
- External IP
- Focused Window
- Load Averages
- Reddit Karma
- TekSavvy Bandwidth
Time to start system last boot.
systemd-analyze | awk '{print $NF}'
Display the amount of time the system took to boot according to systemd.
Check if a daemon is running.
[[ $(pidof "${BLOCK_INSTANCE:-ssh}" &> /dev/null) ]] && echo 'Running' || echo 'Down'
This blocklet will display if the specified process is running. This can test for any process, not just daemons. However, the most likely use of this is to test if desired servers are still working. Just set the instance variable to the basename of the program running to see if its up or down. Some examples are sshd
and mpd
. To display nothing when the service is down instead, remove || echo 'Down'
from the end of the command. Of course your desired up and down text may replace Running
and Down
respectively.
Check if a path exists, can be used to replace path_exists commands if you are migrating from i3status
[ -e ${BLOCK_INSTANCE} ] && (echo yes; echo yes; echo #00FF00) || (echo no; echo no; echo #FF0000)
Feel free to change "yes", "no" and the colors to your liking.
Remaining partition capacity.
df -h -P -l "${BLOCK_INSTANCE:-$HOME}" | awk '/\// { print $4 }'
The instance variable is used to select the path used for calculating the remaining space. For example instance=/boot
calculates the remaining space in the partition where /boot
resides. If /boot
was in the /
partition, this blocklet would report the remaining space in the root partition. Without an instance variable, the blocklet uses your home folder.
Publicly Reachable IP Address.
curl 'ifconfig.me/ip'
http://ifconfig.me/ is a website that returns just your public IP address in plain text when queried by curl
.
Name of the currently focused window.
xdotool getactivewindow getwindowname 2>/dev/null || echo "None"
Use xdotool
to report the current window title. This blocklet will display "None" when no window is currently focused. To display nothing when no window has focus, remove || echo "None"
from the end of the script.
System load average(s).
awk '{print $1,$2,$3}' /proc/loadavg
Display the one, five, and/or fifteen minute load average of the system. Including $1
displays the 1 minute load average, $2
the five minute, and $3
the fifteen.
User's link and comment karma.
curl -s http://www.reddit.com/user/${BLOCK_INSTANCE:-$USER}/about.json | jq '.data.link_karma'
curl -s http://www.reddit.com/user/${BLOCK_INSTANCE:-$USER}/about.json | jq '.data.comment_karma'
Keep up to date with any account's current link and comment karma. This script uses the instance variable to select your username. If no instance variable is defined, it will try your system login username. For example instance=my_username
will return the values for the user "my_username". This version depends on jq
to parse out JSON information. You could just as easily use Perl, Python, Jshon, jsawk, underscore, awk, sed or even coreutils. It's personal preference.
Canadian ISP TekSavvy bandwidth usage.
curl -sLH 'TekSavvy-APIKey: ###_YOUR_API_KEY_###' 'https://api.teksavvy.com/web/Usage/UsageSummaryRecords' | jq '.value[-1:][].OnPeakDownload'
curl -sLH 'TekSavvy-APIKey: ###_YOUR_API_KEY_###' 'https://api.teksavvy.com/web/Usage/UsageRecords?$skip=56' | jq '.value[-1:][].OnPeakDownload'
If you did not know, TekSavvy has a customer API available with a portal account. Register for your portal account at https://myaccount.teksavvy.com/. Once you have one, create an API key My Account > API Key Management
. The above code will display your current month's bandwidth used and how much you used yesterday. Replace ###_YOUR_API_KEY_###
with your API key. You cannot use the instance variable because the length of text it will pass is not long enough. The first script shows monthly usage, the second shows yesterday's. You cannot get today's from the API.
Main Info 📖
- Home 🏠
-
FAQ
⚠️ - Installation 💾
Blocklets 📦
- Boot Time
- Daemon Status
- Disk Capacity
- External IP
- Focused Window
- Load Averages
- Reddit Karma
- TekSavvy Bandwidth
Developers 🔧
- Contributing ❤️
- README Template 📝
- License ©️