Skip to content

Commit fd87c27

Browse files
committed
Fix: default to zero when swapsize not found
1 parent 7799afd commit fd87c27

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bin/omarchy-hibernation-available

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
22
# Checks if swap is big enough to hibernate
33

4-
SWAPSIZE=$(( 1024 * $(cat /proc/swaps |grep -v -e "Filename" -e "zram"| awk '{print $3}') ));
4+
SWAPSIZE_KB=$(cat /proc/swaps |grep -v -e "Filename" -e "zram"| awk '{print $3}');
5+
SWAPSIZE=$(( 1024 * ${SWAPSIZE_KB:-0} ));
56
HIBERNATION_IMAGE_SIZE=$(cat /sys/power/image_size)
6-
if [ "${SWAPSIZE:-0}" -gt "$HIBERNATION_IMAGE_SIZE" ]; then
7+
if [ "${SWAPSIZE}" -gt "$HIBERNATION_IMAGE_SIZE" ]; then
78
exit 0;
89
else
910
exit 1;

0 commit comments

Comments
 (0)