Handy scripts you'd like to share

I’ve been experimenting with Waydroid and sometimes it really bogs down Plasma, so I just wrote some wacky aliases to free up all available memory and restart plasmashell and kwin_x11 and shutdown Waydroid:

# FLUSH - Flush the page-cache, dentries, inodes, sync flush the file system buffer, and stop and restart swap
alias flush='su -c "echo 3 >'/proc/sys/vm/drop_caches' && swapoff -a && swapon -a  && echo && echo -e "ram_cache-swap_cleared" && echo"'

# NUKE -Kill & Restart Plasmashell & Kwin_X11
alias nuke='bash -c "systemctl --user restart plasma-plasmashell > /dev/null 2>&1 & disown; sleep 2; systemctl --user restart plasma-kwin_x11.service > /dev/null 2>&1 & disown; sleep 2 && echo && echo -e "Plasmashell_and_Kwin_X11_nuked_and_restarted"; exit"'

# KILLDROID - Shutdown Waydoid & Weston
alias killdroid='pkill weston && unset WAYLAND_DISPLAY && sudo waydroid container stop && waydroid session stop && sleep 2 && systemctl --user stop clipboard-sync'

If I want to run all three aliases at once I simply execute:

killdroid && nuke && flush

When executed all together this is the output:

htpc@htpc2: /home/htpc
Mon Jul 07 05:16 PM
$ killdroid && nuke && flush
[sudo] password for htpc:

Plasmashell_and_Kwin_X11_nuked_and_restarted
Password:

ram_cache-swap_cleared

htpc@htpc2: /home/htpc
Mon Jul 07 05:16 PM
$

Certainly not my best code attemt, but it works. :smiley:

6 Likes