Skip to content

Commit

Permalink
fix(just): Address issues with memory resizing
Browse files Browse the repository at this point in the history
- Recursive invokations need to be done with --unstable
- Add zram-size declaration if it doesn't exist
- Only fetch the current size, not the entire file contents
  • Loading branch information
EyeCantCU committed Jul 25, 2023
1 parent 3eb3f67 commit 0710ca3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
22 changes: 15 additions & 7 deletions system_files/deck/usr/share/ublue-os/just/custom.just
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ deckswap-off:
resize-deckswap:
#!/usr/bin/env bash
CONFIG='/etc/default/deckswap'
CURRENT_SIZE=$(cat "${CONFIG}" | sed 's/SWAP_SIZE=//g')
CURRENT_SIZE=$(cat "${CONFIG}" | grep "SWAP_SIZE" | sed 's/SWAP_SIZE=//g')
echo 'Current size: '${CURRENT_SIZE}
read -p 'Enter new size (1-16) in gigabytes (1G): ' NEW_SIZE
if [ -z "${NEW_SIZE//[0-9]}" ]; then
Expand All @@ -93,11 +93,11 @@ resize-deckswap:
echo 'Current size: '${NEW_SIZE}'G. Please reboot.'
else
echo 'Error: Input out of range (1-16). Running again.'
just resize-deckswap
just --unstable resize-deckswap
fi
else
echo 'Error: Input is not an integer. Running again.'
just resize-deckswap
just --unstable resize-deckswap
fi
enable-duperemove:
Expand Down Expand Up @@ -130,23 +130,31 @@ zram-off:
resize-zram:
#!/usr/bin/env bash
CONFIG='/etc/systemd/zram-generator.conf'
CURRENT_SIZE=$(cat "${CONFIG}" | sed 's/zram-size=//g')
if grep "zram-size" <<< $(cat ${CONFIG}); then
CURRENT_SIZE=$(cat "${CONFIG}" | grep "zram-size" | sed 's/zram-size=//g')
else
CURRENT_SIZE=1024
fi
echo 'Current size: '${CURRENT_SIZE}
read -p 'Enter new size (512-4096) in megabytes (1024): ' NEW_SIZE
if [ -z "${NEW_SIZE//[0-9]}" ]; then
if [ -z "${NEW_SIZE}" ]; then
NEW_SIZE=1024
fi
if ((${NEW_SIZE} >= 512 && ${NEW_SIZE} <= 4096)); then
sudo sed -i 's/zram-size='${CURRENT_SIZE}'/zram-size='${NEW_SIZE}'/g' ${CONFIG}
if grep "zram-size" <<< $(cat ${CONFIG}); then
sudo sed -i 's/zram-size='${CURRENT_SIZE}'/zram-size='${NEW_SIZE}'/g' ${CONFIG}
else
sudo -A echo "zram-size=${NEW_SIZE}" >> ${CONFIG}
fi
echo 'Current size: '${NEW_SIZE}'. Please reboot.'
else
echo 'Error: Input out of range (512-4096). Running again.'
just resize-zram
just --unstable resize-zram
fi
else
echo 'Error: Input is not an integer. Running again.'
just resize-zram
just --unstable resize-zram
fi
hide-grub:
Expand Down
16 changes: 12 additions & 4 deletions system_files/desktop/usr/share/ublue-os/just/custom.just
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,31 @@ zram-off:
resize-zram:
#!/usr/bin/env bash
CONFIG='/etc/systemd/zram-generator.conf'
CURRENT_SIZE=$(cat "${CONFIG}" | sed 's/zram-size=//g')
if grep "zram-size" <<< $(cat ${CONFIG}); then
CURRENT_SIZE=$(cat "${CONFIG}" | grep "zram-size" | sed 's/zram-size=//g')
else
CURRENT_SIZE=1024
fi
echo 'Current size: '${CURRENT_SIZE}
read -p 'Enter new size (512-4096) in megabytes (1024): ' NEW_SIZE
if [ -z "${NEW_SIZE//[0-9]}" ]; then
if [ -z "${NEW_SIZE}" ]; then
NEW_SIZE=1024
fi
if ((${NEW_SIZE} >= 512 && ${NEW_SIZE} <= 4096)); then
sudo sed -i 's/zram-size='${CURRENT_SIZE}'/zram-size='${NEW_SIZE}'/g' ${CONFIG}
if grep "zram-size" <<< $(cat ${CONFIG}); then
sudo sed -i 's/zram-size='${CURRENT_SIZE}'/zram-size='${NEW_SIZE}'/g' ${CONFIG}
else
sudo -A echo "zram-size=${NEW_SIZE}" >> ${CONFIG}
fi
echo 'Current size: '${NEW_SIZE}'. Please reboot.'
else
echo 'Error: Input out of range (512-4096). Running again.'
just resize-zram
just --unstable resize-zram
fi
else
echo 'Error: Input is not an integer. Running again.'
just resize-zram
just --unstable resize-zram
fi
hide-grub:
Expand Down

0 comments on commit 0710ca3

Please sign in to comment.