Skip to content

Commit 01ecbaf

Browse files
authored
feat(deck): Enhance and fix zram and deckswap scripts (#512)
* fix(resize-zram/deckswap): Prevent multiple sizes from being defined Replaces whatever value is there with the new value * fix(deckswap): Enable/disable instantaneously No need to reboot * feat(resize-zram/deckswap): Resize instantaneously without reboots
1 parent d640471 commit 01ecbaf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

system_files/deck/shared/usr/share/ublue-os/just/60-custom.just

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ deckswap-on:
276276
#!/usr/bin/env bash
277277
STATUS=$(systemctl status deckswap.service)
278278
if grep -q 'inactive' <<< ${STATUS}; then
279-
systemctl enable deckswap.service
280-
echo 'deckswap enabled. Please reboot.'
279+
systemctl enable --now deckswap.service
280+
echo 'deckswap enabled.'
281281
else
282282
echo 'deckswap is already enabled.'
283283
fi
@@ -287,8 +287,8 @@ deckswap-off:
287287
#!/usr/bin/env bash
288288
STATUS=$(systemctl status deckswap.service)
289289
if grep -qv 'inactive' <<< ${STATUS}; then
290-
systemctl disable deckswap.service
291-
echo 'deckswap disabled. Please reboot.'
290+
systemctl disable --now deckswap.service
291+
echo 'deckswap disabled.'
292292
else
293293
echo 'deckswap is already disabled.'
294294
fi
@@ -305,12 +305,13 @@ resize-deckswap:
305305
NEW_SIZE=1
306306
fi
307307
if ((${NEW_SIZE} >= 1 && ${NEW_SIZE} <= 16)); then
308-
sudo sed -i 's/SWAP_SIZE='${CURRENT_SIZE}'G/SWAP_SIZE='${NEW_SIZE}'G/g' ${CONFIG}
309-
echo 'Current size: '${NEW_SIZE}'G. Please reboot.'
308+
sudo sed -i 's/SWAP_SIZE=.*/SWAP_SIZE='${NEW_SIZE}'G/g' ${CONFIG}
309+
echo 'Current size: '${NEW_SIZE}'G.'
310310
else
311311
echo 'Error: Input out of range (1-16). Running again.'
312312
ujust resize-deckswap
313313
fi
314+
systemctl restart deckswap.service
314315
else
315316
echo 'Error: Input is not an integer. Running again.'
316317
ujust resize-deckswap
@@ -361,11 +362,13 @@ resize-zram:
361362
fi
362363
if ((${NEW_SIZE} >= 512 && ${NEW_SIZE} <= 4096)); then
363364
if grep -q "zram-size" <<< $(cat ${CONFIG}); then
364-
sudo sed -i 's/zram-size='${CURRENT_SIZE}'/zram-size='${NEW_SIZE}'/g' ${CONFIG}
365+
sudo sed -i 's/zram-size=.*/zram-size='${NEW_SIZE}'/g' ${CONFIG}
365366
else
366367
sudo echo "zram-size=${NEW_SIZE}" >> ${CONFIG}
367368
fi
368-
echo 'Current size: '${NEW_SIZE}'. Please reboot.'
369+
systemctl daemon-reload
370+
systemctl start /dev/zram0
371+
zramctl
369372
else
370373
echo 'Error: Input out of range (512-4096). Running again.'
371374
ujust resize-zram

0 commit comments

Comments
 (0)