Skip to content

Instantly share code, notes, and snippets.

@prateekrajgautam
Last active January 27, 2024 07:52
Show Gist options
  • Select an option

  • Save prateekrajgautam/be6ae7b917f992b1fc1a029ce622988d to your computer and use it in GitHub Desktop.

Select an option

Save prateekrajgautam/be6ae7b917f992b1fc1a029ce622988d to your computer and use it in GitHub Desktop.
Script to enable hibernation on linuxmint

Enable Hibernate on Linuxmint.sh

#!/bin/bash
echo Script to enable hybernation in linuxmint


sudo apt install pm-utils -y && sudo pm-hibernate

#GET UUID
pattern='(?<=UUID=)([^ ]*)'
#echo "UUID="
#grep swap /etc/fstab | grep -oP "$pattern"
UUID=""$(grep swap /etc/fstab | grep -oP "$pattern")""
echo "UUID=" 
echo $UUID

search='GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"' 
replace='#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=$UUID"'

sudo cp /etc/default/grub /etc/default/grub.bak
sudo sed -i 's/$search/$replace/g' /etc/default/grub

sudo update-grub

systemctl hibernate

shordcut='[Enable hibernate]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes'

sudo $shordcut > /etc/polkit-1/localauthority/90-mandatory.d/enable-hibernate.pkla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment