Disable sleep mode(suspend) during download large file (dynamic ways)

I do search about disable sleep mode(suspend) while downloading large files but with dynamic or automatic ways. i found that:
1-there r download apps have these features in it like fdm:
image

2-there r download apps have event scripter plugin(jdownloader): that can allow u to add command to disable sleep mode on download starting and enable it at event download stopped.
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/inactivity-on-ac -s 0 (that command in xfce, if anyone know the equivalent in gnome can put it in comments)

3- for downloading that can be done by terminal or by python console or any command run in terminal we can run it like that:
sudo systemd-inhibit --mode=block --what=sleep apt-get update

4- if we want app or process to auto activate presentation mode during it's running and inactive it after close we can use script like that:
(xfce command)

#!/bin/bash

# Set initial download status to "inactive"
status="inactive"

while true; do
    # Check if wget is running
    if pgrep -x "wget" > /dev/null
    then
        # If download is active and status is "inactive", disable power saving
        if [ "$status" = "inactive" ]
        then
            xfconf-query --channel xfce4-power-manager --property /xfce4-power-manager/presentation-mode --set true
            status="active"
        fi
    else
        # If download is inactive and status is "active", enable power saving
        if [ "$status" = "active" ]
        then
            xfconf-query --channel xfce4-power-manager --property /xfce4-power-manager/presentation-mode --set false
            status="inactive"
        fi
    fi
    
    # Wait for 5 seconds before checking again
    sleep 5
done

5- if u r using the default downloader of the browser chrome or ms edge, u can use extension it's name caffeine, which has option disable sleep mode during download file automatically
Caffeine - Keep Awake - Chrome Web Store

6-system sleep mode (suspend)disconnect the internet, but display sleep mode(display power managment) not disconnect the internet, but there is pc has wifi power management, and that what Aravisian talked about in his post.

that what i searched and what i think, if anyone has more knowledge or correction or addation , i wish if he shares it

1 Like

You can set this up as an alias in .bashrc, maybe nosleep or nslp so you only have to type the command behind it. This would be great for updates or wget and curl.

2 Likes