You are not logged in.

#1 2024-05-18 04:51:55

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Add Hibernate to bl-exit options?

After upgrading my laptop to Boron I tried, just to see what happened:

systemctl hibernate

Considering it's an encrypted disk, including the swap partition (though grub is not encrypted), I was quite surprised that it worked without a hitch. I was asked for the decryption password on the next boot, as usual, and was returned to my desktop as it was before. All I had done was make sure the swap partition was bigger than RAM, no other special preparations.

I wonder how many machines can hibernate OOTB like that?
I could see the value on a laptop, where even Suspend will drain some battery.

Is there any point in adding Hibernate to the bl-exit menu?

Would it need to do some tests to see if the machine it's running on can support Hibernate before displaying it in the menu?

Should we do a survey of users asking whether 'systemctl hibernate' works for them, and whether they'd use it if it was on the menu?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#2 2024-05-18 13:33:22

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Add Hibernate to bl-exit options?

Is there any point in adding Hibernate to the bl-exit menu?

Just for completeness, sure.

Would it need to do some tests to see if the machine it's running on can support Hibernate before displaying it in the menu?

No, hibernate varies from laptop to laptop; you'd just be chasing your tail.

Should we do a survey of users asking whether 'systemctl hibernate' works for them, and whether they'd use it if it was on the menu?

Yes (see above answer). Knowing if it works OOTB or knowing what a user had to do to make it work would be good information. The survey thread could also serve as a basic How To for hibernation.


You must unlearn what you have learned.
    -- yoda

Offline

#3 2024-05-18 14:32:03

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,645

Re: Add Hibernate to bl-exit options?

I am a suspend fan.

I have actually never used hibernate. That's why I trust your experience.  wink

Offline

#4 2024-05-18 15:32:02

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Add Hibernate to bl-exit options?

PackRat wrote:

Is there any point in adding Hibernate to the bl-exit menu?

Just for completeness, sure.

Would it need to do some tests to see if the machine it's running on can support Hibernate before displaying it in the menu?

No, hibernate varies from laptop to laptop; you'd just be chasing your tail.

Should we do a survey of users asking whether 'systemctl hibernate' works for them, and whether they'd use it if it was on the menu?

Yes (see above answer). Knowing if it works OOTB or knowing what a user had to do to make it work would be good information. The survey thread could also serve as a basic How To for hibernation.

+1.

In general, I'm more in favor of tutorials on how to add stuff that doesn't work for everybody than the opposite.


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#5 2024-05-18 16:18:44

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,010

Re: Add Hibernate to bl-exit options?

DESKTOP

I have been using the "Suspend" button on my keyboard for the past couple of months or so.
Prior to that I simply shut down.  I still shut down at least once a week.

I still, usually, maybe not all the time, save and shut down running programs or at lease "save the info" first.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#6 2024-05-18 16:51:46

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,010

Re: Add Hibernate to bl-exit options?

DESKTOP

So now I'm curious.
After I hit "Suspend" button it just takes a key press to start things up.

After:

systemctl hibernate

How does one bring a system back to life?

BTW:
Alt+F2+

systemctl suspend

works as well.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#7 2024-05-18 17:13:09

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Add Hibernate to bl-exit options?

Sector11 wrote:

After I hit "Suspend" button it just takes a key press to start things up.

After:

systemctl hibernate

How does one bring a system back to life?

Usually by pressing the power button.


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#8 2024-05-18 17:24:17

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,010

Re: Add Hibernate to bl-exit options?

hhh wrote:
Sector11 wrote:

After I hit "Suspend" button it just takes a key press to start things up.

After:

systemctl hibernate

How does one bring a system back to life?

Usually by pressing the power button.

That makes sense since hibernate powers down, but wanted to ask.

"just in case"

OPINION on hibernate
Saving stuff, shutting down programs and "powering down is faster" and powering back up is S·L·O·W


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#9 2024-05-19 02:21:00

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

Powering up from hibernate is slower than a regular boot-up, presumably because it has to check out the stored session data on the swap partition and restore it.

I never use hibernate on my desktop because suspend works just as well and the small power drain is unimportant. I guess some laptop users might find hibernate useful if their work is in a messy situation that would call for suspend, but they don't want that power drain. Hibernate shuts the machine right down. That might also be more secure than suspend on a machine with encrypted drives. (I have to test suspend on my laptop to see what passwords it asks for when coming back up.)

PackRat wrote:
johnraff wrote:

Would it need to do some tests to see if the machine it's running on can support Hibernate before displaying it in the menu?

No, hibernate varies from laptop to laptop; you'd just be chasing your tail.

I was wondering if the conditions for hibernate support were well-defined and easily tested by a script before displaying the menu. If it was unreliable and/or delayed the menu by more than a few milliseconds then it wouldn't be worth it.

packrat wrote:
johnraff wrote:

Should we do a survey of users asking whether 'systemctl hibernate' works for them, and whether they'd use it if it was on the menu?

Knowing if it works OOTB or knowing what a user had to do to make it work would be good information.

It would be good to know if hibernate on Debian Bookworm worked for most people OOTB or not. And if not, whether it is fixable or not.

hhh wrote:

In general, I'm more in favor of tutorials on how to add stuff that doesn't work for everybody than the opposite.

Right. Maybe the simplest solution is to allow users to configure the menu entries they want to display, with "Hibernate" not shown by default. A small bl-exit config file would be easy to support, with default settings if the user has no such file.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#10 2024-05-19 02:29:57

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Add Hibernate to bl-exit options?

johnraff wrote:

Right. Maybe the simplest solution is to allow users to configure the menu entries they want to display, with "Hibernate" not shown by default. A small bl-exit config file would be easy to support, with default settings if the user has no such file.

I think that's the way to go.

Laptop users on Linux, just a guess here, have already set up hibernate if they're doing multi-app stuff on battery power so they can restore after a recharge, or make sure they watch their battery level so they can save and shutdown, or just find an outlet before doing complex, critical work. I mean, if the power just goes out there's nothing you can do unless you're plugged into a whatchamacallit, a UPS (uninterruptible power supply).


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#11 2024-05-19 16:37:09

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,010

Re: Add Hibernate to bl-exit options?

johnraff wrote:

Right. Maybe the simplest solution is to allow users to configure the menu entries they want to display, with "Hibernate" not shown by default. A small bl-exit config file would be easy to support, with default settings if the user has no such file.

Agree - seems to be the best option.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#12 2024-05-21 01:24:14

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

johnraff wrote:

Maybe the simplest solution is to allow users to configure the menu entries they want to display, with "Hibernate" not shown by default. A small bl-exit config file would be easy to support, with default settings if the user has no such file.

After doing some web searching I've re-thought this a bit. Finding out if hibernation will work or not, and how to enable it, looks quite complicated, and depends on the particular hardware and software in use.

Whether to enable a Hibernate button or not is not a user GUI choice (like wallpaper) IMO, but something for the system administrator.

What this boils down to is that I think the config file should be in /etc/bl-exit/, not in ~/.config/bl-exit/
For a one-user system the only difference is that they'll need to use sudo to edit the file, but it's not something they'll be doing very often.

For the package developers (ie us) it's easier to ship a config file in /etc than to get the user to add something to ~/.config.

---
BTW The command-line interface of bl-exit already offers hibernate, but depending on the system, it's not guaranteed to work.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#13 2024-05-21 02:23:05

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Add Hibernate to bl-exit options?

johnraff wrote:

What this boils down to is that I think the config file should be in /etc/bl-exit/, not in ~/.config/bl-exit/
For a one-user system the only difference is that they'll need to use sudo to edit the file, but it's not something they'll be doing very often.

Couldn't a user also just copy the file from /etc/bl-exit/ to ~/.config/bl-exit/ and edit it there without needing sudo?

For the record, this is what systemctl hibernate gave me on my (Ubuntu) laptop...

❯ systemctl hibernate
Call to Hibernate failed: Sleep verb 'hibernate' is not configured or configuration is not supported by kernel

I did search that error and tried to fix it, and got partially there (needed sudo privileges IIRC), but I gave it up as I felt it wasn't worth it on my laptop. So, yes, very dependent on the on the hardware and software used.


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#14 2024-05-21 05:44:51

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

hhh wrote:
johnraff wrote:

What this boils down to is that I think the config file should be in /etc/bl-exit/, not in ~/.config/bl-exit/
For a one-user system the only difference is that they'll need to use sudo to edit the file, but it's not something they'll be doing very often.

Couldn't a user also just copy the file from /etc/bl-exit/ to ~/.config/bl-exit/ and edit it there without needing sudo?

Sure they could - if bl-exit was set up to look at ~/.config/bl-exit/ - but my point is that choosing whether Hibernate is OK to offer in the exit dialogue or not is not something for the user, it's for the admin. (Even if they're the same person.)

If user A has done all the research, figured out that the hardware doesn't support Hibernate and decided not to have it in the dialogue, it doesn't make much sense for user B to enable it - it still won't work.
Or if user A reads up and edits some system files (as root) so it does work, then user B might just as well have it too.
It's not a user preference like themes or even choice of terminal shell. It's something for the whole system.

Secondary point is that it's easier for the package if bl-exit's config file is in /etc.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#15 2024-05-21 05:51:54

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

hhh wrote:

For the record, this is what systemctl hibernate gave me on my (Ubuntu) laptop...

❯ systemctl hibernate
Call to Hibernate failed: Sleep verb 'hibernate' is not configured or configuration is not supported by kernel

I did search that error and tried to fix it, and got partially there (needed sudo privileges IIRC), but I gave it up as I felt it wasn't worth it on my laptop. So, yes, very dependent on the on the hardware and software used.

Thanks for the testing. From what I read this morning one thing that might affect it is Secure Boot - along with a whole bunch of other things like encryption. And agreed it looks messy. Let's leave it for individual users (or sysadmins) to wrangle with, just making it possible for them to have "Hibernate" in the menu if they succeed.

I think the "high level" DE's like KDE do some of that checking automatically, but I wouldn't be surprised if they sometimes got it wrong anyway...


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#16 2024-05-21 06:09:45

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Add Hibernate to bl-exit options?

johnraff wrote:

From what I read this morning one thing that might affect it is Secure Boot...

Thanks for jogging my memory, UEFI Secure Boot was the warning/error/fail I got where I gave it up.

Yes, I could have configured it. No, I didn't need Hibernate that badly.


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#17 2024-05-22 09:13:22

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

Well I've added some code to bl-exit so it can read a config file and use defaults if there isn't one. Made it possible to enable hibernate, hybrid-sleep or suspend-then-hybernate buttons by editing /etc/bl-exit/bl-exit.conf. Also possible to disable buttons for that matter.
Here's the config file:

# Default values are shown commented-out.
# To override the default, uncomment the line and edit the value.

[settings]
# Some screen locking software does not listen for logind calls,
# screen locking then fails, for such screen lockers set
# LOCK_SCREEN_COMMAND="what-locks-screen  --now"
# Known tested examples: "i3lock", "slock", "xscreensaver-command -lock"

#LOCK_SCREEN_COMMAND=""

[showbutton]
# Choose which buttons to display in the yad exit dialog.
# The appropriate commands will be passed to logind.
# However, the buttons currently set to "false" have not been tested and
# may not work with certain hardware and/or software.

#logout = true
#lock = true
#suspend = true
#hibernate = false
#hybrid-sleep = false
#suspend-then-hibernate = false
#reboot = true
#poweroff = true

Are those comments enough?

I did a quick test on my Beryllium desktop and hibernate, hybrid-sleep and suspend-then-hybernate all seemed to work, sort-of. On booting back up I wasn't thrilled to see a brief view of my desktop before typing the login password. I suppose that must be a known lightdm bug?

And here's the modified bl-exit. If you want to test it, copy it to ~/bin and make it executable:

#!/usr/bin/env bash
#
#    bl-exit: Bunsenlabs exit dialog, offering various exit options
#     via both GUI and CLI
#    Copyright: 2019 MXStuff.org <init.choice@mxstuff.org>
#               2019 hhh <hsumen@bunsenlabs.org>
#               2019-2024 John Crawley <john@bunsenlabs.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

########################################################################
##                                                                    ##
## Init and desktop agnostic "yad" based Logout/Exit dialogue.        ##
##                                                                    ##
## Written in response to the seemingly widely held belief that      ##
## 'systemctl' is what you _have_ to use for power operations if you  ##
## have systemd, regardless that dbus calls are arguably superior.    ##
##                                                                    ##
## Since systemd users like systemd specific commands so much, here's ##
## a system exit dialogue that uses systemd's calls for every power   ##
## or session control action, while remaining compatible with         ##
## non-systemd systems.                                               ##
##                                                                    ##
## Originally written for Bunsenlabs "Lithium" by Bearded_Blunder     ##
## <init.choice@mxstuff.org> February 2019                            ##
##                                                                    ##
## Copyright © 2019 MXStuff.org <init.choice@mxstuff.org>             ##
##                                                                    ##
## This program is free software. It comes without any warranty, to   ##
## the extent permitted by applicable law. You can redistribute it    ##
## and/or modify it under the terms of the Do What The Fuck You Want  ##
## To Public License, Version 2, as published by Sam Hocevar. See     ##
## http://www.wtfpl.net/ for more details.                            ##
##                                                                    ##
########################################################################

### Usage ###
USAGE="\nbl-exit [OPTION]\n\n\
With no arguments default yad (GUI) or text menu at a TTY\n\n\
Only one argument is read, they cannot be combined\n\
    -h --help\tShow this help\n\
    -k --lock\tLock screen\tDoes not work for a tty session\n\
    -l --logout\tLogout\t\tAlso works for tty.\n\
    -s --suspend\tSuspend\tState determined by ACPI S0 S1 or S3\n\
    -i --hibernate\tSuspend to Disk\tRequires enough swap to store RAM\n\
    -y --hybrid\tHybrid Sleep\tACPI must support sleep state S3\n\
    -u --suspend-hibernate\tSuspend then Hibernate\tThis option is untested\n\
    -b --reboot\tReboot\n\
    -p --poweroff\tShut down\n\n\

NOTE: Screen locking is done via loginctl, and only available if
called directly as 'bl-exit --lock'.
In BunsenLabs the bl-lock utility is available which uses light-locker.
"

lock_tty_msg="Error: Graphical environment needed for screen locking.
It can be done with the vlock package installed, using the
command 'vlock'. This script does not handle that case.
If you have a graphical environment running the probable cause
of seeing this message is that no display manager is installed.
"

########################################################################

# Default settings:

# Some screen locking software does not listen for logind calls,
# screen locking then fails, for such screen lockers set
# LOCK_SCREEN_COMMAND="what-locks-screen  --now"
LOCK_SCREEN_COMMAND=""
# Known tested examples: "i3lock", "slock", "xscreensaver-command -lock"

# Which buttons to show in yad dialog by default.
# These can be changed in the config file /etc/bl-exit/bl-exit.conf
declare -A showbutton
showbutton=(
    [logout]=true
    [lock]=true
    [suspend]=true
    [hibernate]=false
    [hybrid-sleep]=false
    [suspend-then-hibernate]=false
    [reboot]=true
    [poweroff]=true
)

# Sysadmins can change the above configurations by editing this file:
config_file=/etc/bl-exit/bl-exit.conf

########################################################################

# Configuration of yad buttons - labels, icons and commands:
declare -A yadbutton
yadbutton=(
    [logout]='--button= _Logout!system-log-out:bash -c "logoutctl terminate-session"'
    [lock]='--button= Loc_k Screen!system-lock-screen:bash -c "logoutctl lock-session"'
    [suspend]='--button= _Suspend!system-suspend:bash -c "logoutctl suspend"'
    [hibernate]='--button= H_ibernate!system-hibernate:bash -c "logoutctl hibernate"'
    [hybrid-sleep]='--button= H_ybrid Sleep!system-hibernate:bash -c "logoutctl hybrid-sleep"'
    [suspend-then-hibernate]='--button= Suspend then Hibernate!system-hibernate:bash -c "logoutctl suspend-then-hibernate"'
    [reboot]='--button= Re_boot!system-reboot:bash -c "logoutctl reboot"'
    [poweroff]='--button= _Power Off!system-shutdown:bash -c "logoutctl poweroff"'
)

########################################################################
#                  Compatibility function details                      #
#                                                                      #
# logoutctl() takes the following `systemctl` arguments:               #
#                                                                      #
# poweroff reboot suspend hibernate hybrid-sleep                       #
#  suspend-then-hibernate                                              #
#                                                                      #
# Other systemctl arguments are not transferred to the elogind project #
# and will break if a similar systemctl || loginctl approach is used.  #
#                                                                      #
# Also takes $LOCK_SCREEN_COMMAND if defined in config to handle       #
# screen lockers which don't respond to `loginctl lock-session`        #
#                                                                      #
# loginctl lock-/terminate-session is handled here both to provide     #
# central yad closing and for non-standard screen-lock compatibiliy.   #
#                                                                      #
########################################################################

# This function will likely later be moved to bl-includes in bunsen-common.
# see https://forums.bunsenlabs.org/viewtopic.php?id=5570
#
# Usage: parse_config <file> [<default array name>]
# If no default array name is given, it defaults to 'config'.
# If there are [section] headers in file, following entries will be
#  put in array of that name.
# Config arrays may exist already and will appended to or overwritten.
# If preexisting array is not associative, function exits with error.
# New arrays will be created as needed, and remain in the environment.
parse_config(){
    [[ -f $1 ]] || { echo "$1 is not a file." >&2;return 1;}
    local -n config_array="${2:-config}"
    declare -Ag "${!config_array}" || return 1
    local line key value comment_regex section_regex entry_regex
    comment_regex="^[[:blank:]]*#.*$"
    section_regex="^[[:blank:]]*\[[[:blank:]]*([[:alpha:]_][[:alnum:]_]*)[[:blank:]]*\][[:blank:]]*(#.*)?$"
    entry_regex="^[[:blank:]]*([[:alpha:]_][[:alnum:]_-]*)[[:blank:]]*=[[:blank:]]*('[^']+'|\"[^\"]+\"|[^#[:blank:]]+)[[:blank:]]*(#.*)*$"
    while read -r line
    do
        [[ -n $line ]] || continue
        [[ $line =~ $comment_regex ]] && continue
        [[ $line =~ $section_regex ]] && {
            local -n config_array=${BASH_REMATCH[1]}
            declare -Ag "${!config_array}" || return 1
            continue
        }
        [[ $line =~ $entry_regex ]] || continue
        key=${BASH_REMATCH[1]}
        value=${BASH_REMATCH[2]#[\'\"]} # strip quotes
        value=${value%[\'\"]}
        config_array["${key}"]="${value}"
    done < "$1"
}


########################################################################

logoutctl(){
    if [[ -n $YAD_PID ]]; then
        kill -SIGUSR1 $YAD_PID
    fi
    case $1 in
        cancel )
            echo -e "\ncancelled"
            exit 0 ;;
        lock-session )
            echo -e "\n$1"
            [[ -n "$LOCK_SCREEN_COMMAND" ]] && $LOCK_SCREEN_COMMAND || loginctl $1 $XDG_SESSION_ID
            exit $? ;;
        terminate-session )
            echo  -e "\n$1"
            loginctl $1 $XDG_SESSION_ID
            exit $? ;;
        suspend | hibernate | hybrid-sleep | suspend-then-hibernate | reboot | poweroff )
            echo -e "\n$1"
            # The systemd or elogind compatibility magic.   #
            [[ $(command -v systemctl) ]] && systemctl "$1" || loginctl "$1"
            exit $? ;;
    esac
}
export -f logoutctl

# tests
on_terminal(){
    if [[ -t 0 ]]
    then
        if [[ -t 1 && -t 2 ]]
        then
            return 0
        else
            echo "${0}: STDIN is on terminal, but not STDOUT or STDERR" >&2
            exit 1
        fi
    else
        return 1
    fi
}
#on_graphical_session(){
#    case "$( loginctl show-session -p Type $XDG_SESSION_ID )"
#    in
#        'Type=x11'|'Type=wayland')
#            return 0
#            ;;
#        'Type=tty')
#            return 1
#            ;;
#        *)
#            echo "$0: unable to determine session type." >&2
#            exit 1
#            ;;
#    esac
#}
on_graphical_session(){
    [[ -n $DISPLAY || -n $WAYLAND_DISPLAY ]] && return 0
    return 1
}

# only display this on a TTY
tty_menu(){
    clear
    PS3="Please choose an option "
    select option in Logout Suspend Hibernate Hybrid-Sleep Suspend-then-Hibernate Reboot Power-Off Quit-Dialogue
    do
        case $option in
            Logout)        logoutctl terminate-session;;
            Suspend)       logoutctl suspend;;
            Hibernate)     logoutctl hibernate;;
            Hybrid-Sleep)  logoutctl hybrid-sleep;;
            Suspend-then-Hibernate) logoutctl suspend-then-hibernate;;
            Reboot)        logoutctl reboot;;
            Power-Off)     logoutctl poweroff;;
            Quit-Dialogue) echo 'exit cancelled';;
        esac
        break
    done
}

# can only use this in a graphical session
yad_gui() {
    buttons=()
    for b in logout lock suspend hibernate hybrid-sleep suspend-then-hibernate reboot poweroff
    do
        case "${showbutton[$b],,}" in
            true|yes|y|1)
            buttons+=("${yadbutton[$b]}") ;;
        esac
    done
    yad --class=WmanExit --title "Exit" --close-on-unfocus --undecorated --center --on-top --borders=10 --window-icon=system-log-out \
    "${buttons[@]}"
}

[[ -r "$config_file" ]] && parse_config "$config_file"|| echo "${0}: failed to parse $config_file, using default settings." >&2
[[ -n "${settings[LOCK_SCREEN_COMMAND]}" ]] && LOCK_SCREEN_COMMAND=${settings[LOCK_SCREEN_COMMAND]}

case "$1" in
    -h|--help)
        echo -e "$USAGE"
        ;;
    -k|--lock)
        if on_graphical_session
        then
            logoutctl lock-session
        else
            echo "$0: $lock_tty_msg" >&2
            exit 1
        fi
        ;;
    -l|--logout)
        logoutctl terminate-session
        ;;
    -s|--suspend)
        logoutctl suspend
        ;;
    -i|--hibernate)
        logoutctl hibernate
        ;;
    -y|--hybrid)
        logoutctl hybrid-sleep
        ;;
    -u| --suspend-hibernate)
        logoutctl suspend-then-hibernate
        ;;
    -b|--reboot)
        logoutctl reboot
        ;;
    -p|--poweroff)
        logoutctl poweroff
        ;;
    '')
        if on_terminal
        then
            tty_menu
        elif on_graphical_session
        then
            yad_gui
        else
            echo "$0: No exit option passed,
and unable to display exit menu." >&2
            exit 1
        fi
        ;;
    *)
        echo "$0: Unknown operation $1"
        echo -e "$USAGE"
        exit 1
        ;;
esac

Last edited by johnraff (2024-05-29 02:10:49)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#18 2024-05-22 09:51:09

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Add Hibernate to bl-exit options?

Looks good. I'll test it out later today.

Edit - It's working as expected.


You must unlearn what you have learned.
    -- yoda

Offline

#19 2024-05-23 03:21:23

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

^Thanks for checking!
I guess it will be safe to upgrade bunsen-exit with that stuff. It's only the hibernate-related options that might cause issues, and they're disabled by default, just as now.

We can post a warning that some people might need to do research to get those options working.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#20 2024-05-29 05:34:44

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 1,146

Re: Add Hibernate to bl-exit options?

Of the options when I was playing, I found hibernate better supported on old hardware than some of the other states. Of course it does require a user has enough swap configured to write the entire content of RAM to, in addition to any of the swap already in use, that'd be fairly easy to script checking, I know if someone uses the defaults in D-I it configures enough, or used to be, all bets are off if they do manual partitioning, I've not done a clean install of the current version to see what it does WRT swap.

On newer hardware ACPI is less flaky than it used to be, I'd beware of simply enabling hybrid sleep without doing some research, though I think Windows 10 & 11 do, not without creating some issues in the case of 10 on old hardware.

If you were going to chance enabling the hibernate button automagically  You'd be wanting to compare the amount of swap & RAM & probably test the content of /sys/power/state includes disk

cat /sys/power/state

Will list the available sleep states the system declares it can do. It does so in words though.

I'm not sure without looking how to twist Linux's tail to tell me if a system supports the "S3" power state though, & my Google-fu is weak tonight, that's the vital one for hybrid-sleep to function, & it's sometimes flaky on older hardware. (At least the sort of 12 to 15 year old hardware I have ready access to).

I haven't played with what works & what doesn't on real hardware in a long time (My laptop still has Lithium-dev on it & hasn't been booted since before the official Lithium release) I seem to remember some of the ones like hybrid-sleep or suspend-then-hibernate giving some issues, mind it was cranky about hybrid-sleep under Windows too, but then it's ancient.

[edit]
Afterthought, with mind on possible tweaks for Carbon, once you start adding buttons the dialogue starts getting a tad wide, might be worth considering a minor tweak to the yad to stack them vertically.
It'd make it more harmonious with the menu system aesthetically, & would make the addition of a potentially uesful cancel option feasible without it becoming a ribbon right across the screen.
[/edit]

Last edited by Bearded_Blunder (2024-05-29 06:01:11)


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

Board footer

Powered by FluxBB