add swap support

This commit is contained in:
koksnuss 2018-05-14 00:53:21 +02:00
parent c7d9be3434
commit d719a45bf7
3 changed files with 11 additions and 5 deletions

View File

@ -11,13 +11,14 @@ Adjust `~/.config/i3blocks/config` to control i3 status bar output. Finally relo
# Requirements # Requirements
The following shows the requirements for each script: The following shows the requirements for each script:
```bash ```bash
audio amixer audio,mic amixer
battery none, searches in /sys/class/power_supply/BAT... battery none, searches in /sys/class/power_supply/BAT...
cpu top cpu top
datetime date datetime date
ip curl ip curl
ram none, searches in /proc/meminfo ram,swap none, searches in /proc/meminfo
storage df storage df
backlight none, searches in /sys/class/backlight, intel and ati/amd supported
``` ```
# Roadmap # Roadmap
@ -33,7 +34,7 @@ storage df
- [x] cpu - [x] cpu
- [x] backlight - [x] backlight
- [x] microphone - [x] microphone
- [ ] swap - [x] swap
- [ ] wifi/ethernet/bluetooth - [ ] wifi/ethernet/bluetooth
- [ ] external storage with mount - [ ] external storage with mount
- [ ] ethernet bandwith - [ ] ethernet bandwith

4
config
View File

@ -14,6 +14,10 @@ label=storage
[ram] [ram]
label=ram label=ram
[ram]
label=swap
instance=swap
[cpu] [cpu]
label=cpu label=cpu

5
ram
View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
gawk ' [[ ${BLOCK_INSTANCE} == 'swap' ]] && TYPE="SwapFree" || TYPE="MemAvailable"
/^MemAvailable:/ { gawk -v type="$TYPE" '
$0 ~ type {
mfg=$2/1024^2 mfg=$2/1024^2
mfm=$2/1024 mfm=$2/1024
} }