Hibernate function?


#21

Oh yeah, today I finally managed to get hibernation working as I wanted:
rofi-logout

First, kernel must have option to resume, as I use GRUB, edited file /etc/default/grub to add resume option to line GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=LABEL=swap"

It didn’t worked until I remembered I may have been to lazy to label my swap partition.
Unmount:
sudo swapoff -a
Write label:
sudo mkswap -L swap /dev/sda5
Mount:
sudo swapon /dev/sda5

Then, add a hook to mkinitcpio: whereis mkinitcpio.conf -> edit /etc/mkinitcpio.conf and add resume to the line starting with HOOK, example: HOOKS=(base udev autodetect ide sata resume filesystems)
make initramfs:
sudo mkinitcpio -p linux
Now I can hibernate with systemctl hibernate and even systemctl hybrid-sleep what suspend to RAM while preparing for hibernation, in case battery went off. But still no option in the menu. Looking up the keyboard shortcut in the openbox configuration, Super+x is bound to rofi_run -l. editing the -l section in the file found at whereis rofi_run I realized the icons are just font symbols. Searching internet for ⏻ brought me to ⏾ so here is my example:
-l|–logout)
if grep -q ‘exec startx’ $HOME/.*profile; then
ANS="$(rofi -sep “|” -dmenu -i -p ‘System’ -width 20
-hide-scrollbar -line-padding 4 -padding 20
-lines 3 <<< “ Lock| Reboot| Shutdown”
else
ANS="$(rofi -sep “|” -dmenu -i -p ‘System’ -width 20
-hide-scrollbar -line-padding 4 -padding 20
-lines 5 <<< “ Lock| Logout| Reboot| Shutdown|⏾ Sleep”)"
fi

        case "$ANS" in
            *Lock) i3lock-fancy ;;
            *Reboot) systemctl reboot ;;
            *Shutdown) systemctl -i poweroff ;;
            *Logout) session-logout || pkill -15 -t tty"$XDG_VTNR" Xorg ;;
            *Sleep) systemctl hybrid-sleep ;;
        esac
        ;;

#22

Talk about necrobumps hahaha