How do I stop xscreensaver during movies play?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







5















I'm running Ubuntu 12.04. I installed xscreensaver in place of gnome.screensaver.



My problem is that I cannot get the screensaver to stop popping up when I'm watching a movie on Movie Player. I have Movie Player set to disable screensavers but it's not working on xscreensaver.



How do I change the program files to disable xscreensaver while Movie Player is running?










share|improve this question

























  • The XScreenSaver page has this to say about it.

    – Nattgew
    Apr 9 '14 at 19:18











  • Thank you for that. Unfortunately MPlayer doesn't work and I can't find MPV.

    – Chris26284
    Apr 9 '14 at 19:53











  • From the link on that page, you can get to installation packages for MPV here. It appears your options are to upgrade to the upcoming version of Ubuntu or use the PPA.

    – Nattgew
    Apr 9 '14 at 19:59











  • Thank you again. I'll definitely look into MPV and PPAs.

    – Chris26284
    Apr 10 '14 at 2:01











  • This question should be closed and deleted as it doesn't even specify a program. It's like asking "How do I shutdown my computer" without specifying an operating system.

    – Evan Carroll
    Apr 28 '18 at 8:01


















5















I'm running Ubuntu 12.04. I installed xscreensaver in place of gnome.screensaver.



My problem is that I cannot get the screensaver to stop popping up when I'm watching a movie on Movie Player. I have Movie Player set to disable screensavers but it's not working on xscreensaver.



How do I change the program files to disable xscreensaver while Movie Player is running?










share|improve this question

























  • The XScreenSaver page has this to say about it.

    – Nattgew
    Apr 9 '14 at 19:18











  • Thank you for that. Unfortunately MPlayer doesn't work and I can't find MPV.

    – Chris26284
    Apr 9 '14 at 19:53











  • From the link on that page, you can get to installation packages for MPV here. It appears your options are to upgrade to the upcoming version of Ubuntu or use the PPA.

    – Nattgew
    Apr 9 '14 at 19:59











  • Thank you again. I'll definitely look into MPV and PPAs.

    – Chris26284
    Apr 10 '14 at 2:01











  • This question should be closed and deleted as it doesn't even specify a program. It's like asking "How do I shutdown my computer" without specifying an operating system.

    – Evan Carroll
    Apr 28 '18 at 8:01














5












5








5


4






I'm running Ubuntu 12.04. I installed xscreensaver in place of gnome.screensaver.



My problem is that I cannot get the screensaver to stop popping up when I'm watching a movie on Movie Player. I have Movie Player set to disable screensavers but it's not working on xscreensaver.



How do I change the program files to disable xscreensaver while Movie Player is running?










share|improve this question
















I'm running Ubuntu 12.04. I installed xscreensaver in place of gnome.screensaver.



My problem is that I cannot get the screensaver to stop popping up when I'm watching a movie on Movie Player. I have Movie Player set to disable screensavers but it's not working on xscreensaver.



How do I change the program files to disable xscreensaver while Movie Player is running?







video screensaver video-player xscreensaver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '14 at 9:10









user.dz

35.3k1198179




35.3k1198179










asked Apr 9 '14 at 18:57









Chris26284Chris26284

3818




3818













  • The XScreenSaver page has this to say about it.

    – Nattgew
    Apr 9 '14 at 19:18











  • Thank you for that. Unfortunately MPlayer doesn't work and I can't find MPV.

    – Chris26284
    Apr 9 '14 at 19:53











  • From the link on that page, you can get to installation packages for MPV here. It appears your options are to upgrade to the upcoming version of Ubuntu or use the PPA.

    – Nattgew
    Apr 9 '14 at 19:59











  • Thank you again. I'll definitely look into MPV and PPAs.

    – Chris26284
    Apr 10 '14 at 2:01











  • This question should be closed and deleted as it doesn't even specify a program. It's like asking "How do I shutdown my computer" without specifying an operating system.

    – Evan Carroll
    Apr 28 '18 at 8:01



















  • The XScreenSaver page has this to say about it.

    – Nattgew
    Apr 9 '14 at 19:18











  • Thank you for that. Unfortunately MPlayer doesn't work and I can't find MPV.

    – Chris26284
    Apr 9 '14 at 19:53











  • From the link on that page, you can get to installation packages for MPV here. It appears your options are to upgrade to the upcoming version of Ubuntu or use the PPA.

    – Nattgew
    Apr 9 '14 at 19:59











  • Thank you again. I'll definitely look into MPV and PPAs.

    – Chris26284
    Apr 10 '14 at 2:01











  • This question should be closed and deleted as it doesn't even specify a program. It's like asking "How do I shutdown my computer" without specifying an operating system.

    – Evan Carroll
    Apr 28 '18 at 8:01

















The XScreenSaver page has this to say about it.

– Nattgew
Apr 9 '14 at 19:18





The XScreenSaver page has this to say about it.

– Nattgew
Apr 9 '14 at 19:18













Thank you for that. Unfortunately MPlayer doesn't work and I can't find MPV.

– Chris26284
Apr 9 '14 at 19:53





Thank you for that. Unfortunately MPlayer doesn't work and I can't find MPV.

– Chris26284
Apr 9 '14 at 19:53













From the link on that page, you can get to installation packages for MPV here. It appears your options are to upgrade to the upcoming version of Ubuntu or use the PPA.

– Nattgew
Apr 9 '14 at 19:59





From the link on that page, you can get to installation packages for MPV here. It appears your options are to upgrade to the upcoming version of Ubuntu or use the PPA.

– Nattgew
Apr 9 '14 at 19:59













Thank you again. I'll definitely look into MPV and PPAs.

– Chris26284
Apr 10 '14 at 2:01





Thank you again. I'll definitely look into MPV and PPAs.

– Chris26284
Apr 10 '14 at 2:01













This question should be closed and deleted as it doesn't even specify a program. It's like asking "How do I shutdown my computer" without specifying an operating system.

– Evan Carroll
Apr 28 '18 at 8:01





This question should be closed and deleted as it doesn't even specify a program. It's like asking "How do I shutdown my computer" without specifying an operating system.

– Evan Carroll
Apr 28 '18 at 8:01










6 Answers
6






active

oldest

votes


















5














You may try similar script to this one. Watch for player state through DBUS.



I lower delay to 55 sec, work better with 1min screen saver idle time.





  • Example VLC:



    BTW, VLC in Ubuntu 14.04 has DBUS interface enabled by default. Where in Ubuntu 12.04 is not. Check it from:



    Tools → Preferences → Advanced (or All) → Interface → Control Interfaces → D-Bus control interface. (Apply then Restart VLC)





    1. Create a file heartbeat.sh in ~/Desktop/:



      #!/bin/bash

      while sleep 55
      do
      if [ "$(pgrep vlc)" != "" ]
      then
      state=$(bash -c 'gdbus call --session
      --dest org.mpris.MediaPlayer2.vlc
      --object-path /org/mpris/MediaPlayer2
      --method org.freedesktop.DBus.Properties.Get
      "org.mpris.MediaPlayer2.Player"
      "PlaybackStatus"')
      if [ "$state" = "(<'Playing'>,)" ]
      then
      #xscreensaver-command -deactivate
      xset s reset
      fi
      fi
      done


    2. Open terminal Ctrl+Alt+t



    3. Add run permissions:



      chmod +x ~/Desktop/heartbeat.sh



    4. Run script:



      ~/Desktop/heartbeat.sh


    5. Try VLC player.





  • For Gnome MPlayer (D-Bus enabled by default), use:



    "$(pgrep gnome-mplayer)" and
    --dest org.mpris.MediaPlayer2.gnome-mplayer




  • For (Totem) Videos player (D-Bus plugin disabled by default),



    Edit → Plugins → Check D-Bus service. (Restart totem)



    Use:



    "$(pgrep totem)" and
    --dest org.mpris.MediaPlayer2.totem




  • This is modified with to work with any player that provide MPRIS. It gets the list dynamically (drawback, it doesn't distinguish between audio only play and video play). The best way I think is to put manually the list of players you like:



    #!/bin/bash

    players_list=$(gdbus call --session --dest org.freedesktop.DBus
    --object-path / --method org.freedesktop.DBus.ListNames |
    awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

    while sleep 55
    do
    for player in $players_list
    do
    state=$(gdbus call --session
    --dest $player
    --object-path /org/mpris/MediaPlayer2
    --method org.freedesktop.DBus.Properties.Get
    "org.mpris.MediaPlayer2.Player"
    "PlaybackStatus")
    if [ "$state" = "(<'Playing'>,)" ]
    then
    echo $player $state send signal
    #xscreensaver-command -deactivate
    #use xset to work with all screensaver tools and avoid dimming display ...
    xset s reset
    break
    else
    echo $player $state
    fi
    done
    done



Debug hints:





  1. Watch X idle time



    watch -n1 xprintidle


    or:



    while sleep 1; do xprintidle; done;



  2. Check if disabling screensaver works (while running this script, xscreensave should not pop up)



        #!/bin/bash

    while sleep 55
    do
    #xscreensaver-command -deactivate
    #xdg-screensaver reset
    xset s reset
    done



  3. Check for DBUS list for MPRIS player interface, example with VLC running:



        gdbus call --session --dest org.freedesktop.DBus 
    --object-path / --method org.freedesktop.DBus.ListNames |
    awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }'


    Output:



        org.mpris.MediaPlayer2.vlc
    org.mpris.MediaPlayer2.vlc.instance3939


    Or using dbus-send command



        dbus-send --session 
    --dest=org.freedesktop.DBus
    --type=method_call
    --print-reply
    /org/freedesktop/DBus
    org.freedesktop.DBus.ListNames
    | grep org.mpris.MediaPlayer2.


    Output:



        string "org.mpris.MediaPlayer2.vlc"
    string "org.mpris.MediaPlayer2.vlc.instance3939"



References:





  • How to set up DBus query to get play state of VLC? original script by JB0x2D1

  • MPRIS D-Bus Interface Specification

  • Use qdbusviewer to check the correct destination name or to use other player you like.






share|improve this answer


























  • @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

    – user.dz
    Apr 13 '14 at 6:05











  • This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

    – Chris26284
    Apr 15 '14 at 20:37











  • @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

    – user.dz
    May 2 '14 at 8:07











  • I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

    – Chris26284
    May 25 '14 at 0:33











  • @Chris26284, I have updated it to use xset

    – user.dz
    Jun 17 '14 at 19:22



















0














For MPV, and mplayer, the heartbeat functionality is built in.



1) Locate your mpv configuration file. locate mpv.conf



2) Open it up. sudo nano /path/to/mpv.conf



3) Add this line at the bottom. heartbeat-cmd="/usr/bin/xscreensaver-command -deactivate > /dev/null"



4) Close, and save. Ctrl+X if using nano.



Find out where to find your mpv.conf file here (configuration is identical on Arch Linux), https://wiki.archlinux.org/index.php/Mpv#Configuration




If the environment variable XDG_CONFIG_HOME is not set, user configuration files will be read from the ~/.config/mpv directory. System-wide configuration files are read from the /etc/mpv directory.







share|improve this answer































    0














    Here is my own version from Chris' code:



    #!/bin/bash
    while sleep 55
    do
    players_list=$(gdbus call --session --dest org.freedesktop.DBus
    --object-path / --method org.freedesktop.DBus.ListNames |
    awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

    for player in $players_list
    do
    state=$(gdbus call --session
    --dest $player
    --object-path /org/mpris/MediaPlayer2
    --method org.freedesktop.DBus.Properties.Get
    "org.mpris.MediaPlayer2.Player"
    "PlaybackStatus")

    fullscreen=$(gdbus call --session
    --dest $player
    --object-path /org/mpris/MediaPlayer2
    --method org.freedesktop.DBus.Properties.Get
    "org.mpris.MediaPlayer2"
    "Fullscreen")

    if [ "$state" = "(<'Playing'>,)" -a "$fullscreen" = "(<true>,)" ]
    then
    echo $player $state $fullscreen send signal
    xscreensaver-command -deactivate
    break
    else
    echo $player $state $fullscreen
    fi
    done
    done


    It checks at each iteration if the list of players has been changed.



    It also deactivates the screensaver only if the player is fullscreen which is normally the case for video.



    I just put this script in the autostart and don't bother anymore with xscreensaver while watching video.






    share|improve this answer

































      0














      I noticed all the answers here seemed unnecessarily complex; you don't really need to do this based on a specific media player - all you need to do is detect if any audio is playing. I'm actually surprised this isn't a feature built into xscreensaver. Here's a super simple bash script:



      #!/bin/bash

      while true
      do
      state=$(pacmd list-sinks | grep -A 4 "*" | grep "state: " | cut -c 9-)
      if [[ $state == SUSPENDED || $state == IDLE ]]
      then
      echo "State: $state. Not pausing screensaver."
      sleep 2m
      else
      echo "State: $state. Pausing screensaver."
      xscreensaver-command -deactivate > /dev/null
      sleep 4m
      fi
      done





      share|improve this answer

































        0














        This worked for me on Xubuntu 17.10 with xscreensaver



        #!/bin/bash

        while true; do
        sleep 10
        cat /proc/asound/card*/pcm*/sub*/status | grep RUNNING && xscreensaver-command -deactivate
        done





        share|improve this answer































          0














          This worked for me with Xubuntu 18.10 and with VLC, youtube videos, etc... wiithout the need to disable xscreensaver.
          Just add the following script when you system start:



          #!/bin/bash
          # enumerate all the attached screens
          displays=""
          while read id
          do
          displays="$displays $id"
          done< <(xvinfo | sed -n 's/^screen #([0-9]+)$/1/p')

          checkFullscreen()
          {

          # loop through every display looking for a fullscreen window
          for display in $displays
          do
          #get id of active window and clean output
          activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW`
          activ_win_id=${activ_win_id:40:9}

          # Check if Active Window (the foremost window) is in fullscreen state
          isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
          if [[ "$isActivWinFullscreen" == *NET_WM_STATE_FULLSCREEN* ]];then
          xscreensaver-command -deactivate
          fi
          done
          }

          while sleep $((30)); do
          checkFullscreen
          done

          exit 0





          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f445612%2fhow-do-i-stop-xscreensaver-during-movies-play%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            6 Answers
            6






            active

            oldest

            votes








            6 Answers
            6






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            You may try similar script to this one. Watch for player state through DBUS.



            I lower delay to 55 sec, work better with 1min screen saver idle time.





            • Example VLC:



              BTW, VLC in Ubuntu 14.04 has DBUS interface enabled by default. Where in Ubuntu 12.04 is not. Check it from:



              Tools → Preferences → Advanced (or All) → Interface → Control Interfaces → D-Bus control interface. (Apply then Restart VLC)





              1. Create a file heartbeat.sh in ~/Desktop/:



                #!/bin/bash

                while sleep 55
                do
                if [ "$(pgrep vlc)" != "" ]
                then
                state=$(bash -c 'gdbus call --session
                --dest org.mpris.MediaPlayer2.vlc
                --object-path /org/mpris/MediaPlayer2
                --method org.freedesktop.DBus.Properties.Get
                "org.mpris.MediaPlayer2.Player"
                "PlaybackStatus"')
                if [ "$state" = "(<'Playing'>,)" ]
                then
                #xscreensaver-command -deactivate
                xset s reset
                fi
                fi
                done


              2. Open terminal Ctrl+Alt+t



              3. Add run permissions:



                chmod +x ~/Desktop/heartbeat.sh



              4. Run script:



                ~/Desktop/heartbeat.sh


              5. Try VLC player.





            • For Gnome MPlayer (D-Bus enabled by default), use:



              "$(pgrep gnome-mplayer)" and
              --dest org.mpris.MediaPlayer2.gnome-mplayer




            • For (Totem) Videos player (D-Bus plugin disabled by default),



              Edit → Plugins → Check D-Bus service. (Restart totem)



              Use:



              "$(pgrep totem)" and
              --dest org.mpris.MediaPlayer2.totem




            • This is modified with to work with any player that provide MPRIS. It gets the list dynamically (drawback, it doesn't distinguish between audio only play and video play). The best way I think is to put manually the list of players you like:



              #!/bin/bash

              players_list=$(gdbus call --session --dest org.freedesktop.DBus
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

              while sleep 55
              do
              for player in $players_list
              do
              state=$(gdbus call --session
              --dest $player
              --object-path /org/mpris/MediaPlayer2
              --method org.freedesktop.DBus.Properties.Get
              "org.mpris.MediaPlayer2.Player"
              "PlaybackStatus")
              if [ "$state" = "(<'Playing'>,)" ]
              then
              echo $player $state send signal
              #xscreensaver-command -deactivate
              #use xset to work with all screensaver tools and avoid dimming display ...
              xset s reset
              break
              else
              echo $player $state
              fi
              done
              done



            Debug hints:





            1. Watch X idle time



              watch -n1 xprintidle


              or:



              while sleep 1; do xprintidle; done;



            2. Check if disabling screensaver works (while running this script, xscreensave should not pop up)



                  #!/bin/bash

              while sleep 55
              do
              #xscreensaver-command -deactivate
              #xdg-screensaver reset
              xset s reset
              done



            3. Check for DBUS list for MPRIS player interface, example with VLC running:



                  gdbus call --session --dest org.freedesktop.DBus 
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }'


              Output:



                  org.mpris.MediaPlayer2.vlc
              org.mpris.MediaPlayer2.vlc.instance3939


              Or using dbus-send command



                  dbus-send --session 
              --dest=org.freedesktop.DBus
              --type=method_call
              --print-reply
              /org/freedesktop/DBus
              org.freedesktop.DBus.ListNames
              | grep org.mpris.MediaPlayer2.


              Output:



                  string "org.mpris.MediaPlayer2.vlc"
              string "org.mpris.MediaPlayer2.vlc.instance3939"



            References:





            • How to set up DBus query to get play state of VLC? original script by JB0x2D1

            • MPRIS D-Bus Interface Specification

            • Use qdbusviewer to check the correct destination name or to use other player you like.






            share|improve this answer


























            • @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

              – user.dz
              Apr 13 '14 at 6:05











            • This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

              – Chris26284
              Apr 15 '14 at 20:37











            • @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

              – user.dz
              May 2 '14 at 8:07











            • I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

              – Chris26284
              May 25 '14 at 0:33











            • @Chris26284, I have updated it to use xset

              – user.dz
              Jun 17 '14 at 19:22
















            5














            You may try similar script to this one. Watch for player state through DBUS.



            I lower delay to 55 sec, work better with 1min screen saver idle time.





            • Example VLC:



              BTW, VLC in Ubuntu 14.04 has DBUS interface enabled by default. Where in Ubuntu 12.04 is not. Check it from:



              Tools → Preferences → Advanced (or All) → Interface → Control Interfaces → D-Bus control interface. (Apply then Restart VLC)





              1. Create a file heartbeat.sh in ~/Desktop/:



                #!/bin/bash

                while sleep 55
                do
                if [ "$(pgrep vlc)" != "" ]
                then
                state=$(bash -c 'gdbus call --session
                --dest org.mpris.MediaPlayer2.vlc
                --object-path /org/mpris/MediaPlayer2
                --method org.freedesktop.DBus.Properties.Get
                "org.mpris.MediaPlayer2.Player"
                "PlaybackStatus"')
                if [ "$state" = "(<'Playing'>,)" ]
                then
                #xscreensaver-command -deactivate
                xset s reset
                fi
                fi
                done


              2. Open terminal Ctrl+Alt+t



              3. Add run permissions:



                chmod +x ~/Desktop/heartbeat.sh



              4. Run script:



                ~/Desktop/heartbeat.sh


              5. Try VLC player.





            • For Gnome MPlayer (D-Bus enabled by default), use:



              "$(pgrep gnome-mplayer)" and
              --dest org.mpris.MediaPlayer2.gnome-mplayer




            • For (Totem) Videos player (D-Bus plugin disabled by default),



              Edit → Plugins → Check D-Bus service. (Restart totem)



              Use:



              "$(pgrep totem)" and
              --dest org.mpris.MediaPlayer2.totem




            • This is modified with to work with any player that provide MPRIS. It gets the list dynamically (drawback, it doesn't distinguish between audio only play and video play). The best way I think is to put manually the list of players you like:



              #!/bin/bash

              players_list=$(gdbus call --session --dest org.freedesktop.DBus
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

              while sleep 55
              do
              for player in $players_list
              do
              state=$(gdbus call --session
              --dest $player
              --object-path /org/mpris/MediaPlayer2
              --method org.freedesktop.DBus.Properties.Get
              "org.mpris.MediaPlayer2.Player"
              "PlaybackStatus")
              if [ "$state" = "(<'Playing'>,)" ]
              then
              echo $player $state send signal
              #xscreensaver-command -deactivate
              #use xset to work with all screensaver tools and avoid dimming display ...
              xset s reset
              break
              else
              echo $player $state
              fi
              done
              done



            Debug hints:





            1. Watch X idle time



              watch -n1 xprintidle


              or:



              while sleep 1; do xprintidle; done;



            2. Check if disabling screensaver works (while running this script, xscreensave should not pop up)



                  #!/bin/bash

              while sleep 55
              do
              #xscreensaver-command -deactivate
              #xdg-screensaver reset
              xset s reset
              done



            3. Check for DBUS list for MPRIS player interface, example with VLC running:



                  gdbus call --session --dest org.freedesktop.DBus 
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }'


              Output:



                  org.mpris.MediaPlayer2.vlc
              org.mpris.MediaPlayer2.vlc.instance3939


              Or using dbus-send command



                  dbus-send --session 
              --dest=org.freedesktop.DBus
              --type=method_call
              --print-reply
              /org/freedesktop/DBus
              org.freedesktop.DBus.ListNames
              | grep org.mpris.MediaPlayer2.


              Output:



                  string "org.mpris.MediaPlayer2.vlc"
              string "org.mpris.MediaPlayer2.vlc.instance3939"



            References:





            • How to set up DBus query to get play state of VLC? original script by JB0x2D1

            • MPRIS D-Bus Interface Specification

            • Use qdbusviewer to check the correct destination name or to use other player you like.






            share|improve this answer


























            • @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

              – user.dz
              Apr 13 '14 at 6:05











            • This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

              – Chris26284
              Apr 15 '14 at 20:37











            • @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

              – user.dz
              May 2 '14 at 8:07











            • I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

              – Chris26284
              May 25 '14 at 0:33











            • @Chris26284, I have updated it to use xset

              – user.dz
              Jun 17 '14 at 19:22














            5












            5








            5







            You may try similar script to this one. Watch for player state through DBUS.



            I lower delay to 55 sec, work better with 1min screen saver idle time.





            • Example VLC:



              BTW, VLC in Ubuntu 14.04 has DBUS interface enabled by default. Where in Ubuntu 12.04 is not. Check it from:



              Tools → Preferences → Advanced (or All) → Interface → Control Interfaces → D-Bus control interface. (Apply then Restart VLC)





              1. Create a file heartbeat.sh in ~/Desktop/:



                #!/bin/bash

                while sleep 55
                do
                if [ "$(pgrep vlc)" != "" ]
                then
                state=$(bash -c 'gdbus call --session
                --dest org.mpris.MediaPlayer2.vlc
                --object-path /org/mpris/MediaPlayer2
                --method org.freedesktop.DBus.Properties.Get
                "org.mpris.MediaPlayer2.Player"
                "PlaybackStatus"')
                if [ "$state" = "(<'Playing'>,)" ]
                then
                #xscreensaver-command -deactivate
                xset s reset
                fi
                fi
                done


              2. Open terminal Ctrl+Alt+t



              3. Add run permissions:



                chmod +x ~/Desktop/heartbeat.sh



              4. Run script:



                ~/Desktop/heartbeat.sh


              5. Try VLC player.





            • For Gnome MPlayer (D-Bus enabled by default), use:



              "$(pgrep gnome-mplayer)" and
              --dest org.mpris.MediaPlayer2.gnome-mplayer




            • For (Totem) Videos player (D-Bus plugin disabled by default),



              Edit → Plugins → Check D-Bus service. (Restart totem)



              Use:



              "$(pgrep totem)" and
              --dest org.mpris.MediaPlayer2.totem




            • This is modified with to work with any player that provide MPRIS. It gets the list dynamically (drawback, it doesn't distinguish between audio only play and video play). The best way I think is to put manually the list of players you like:



              #!/bin/bash

              players_list=$(gdbus call --session --dest org.freedesktop.DBus
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

              while sleep 55
              do
              for player in $players_list
              do
              state=$(gdbus call --session
              --dest $player
              --object-path /org/mpris/MediaPlayer2
              --method org.freedesktop.DBus.Properties.Get
              "org.mpris.MediaPlayer2.Player"
              "PlaybackStatus")
              if [ "$state" = "(<'Playing'>,)" ]
              then
              echo $player $state send signal
              #xscreensaver-command -deactivate
              #use xset to work with all screensaver tools and avoid dimming display ...
              xset s reset
              break
              else
              echo $player $state
              fi
              done
              done



            Debug hints:





            1. Watch X idle time



              watch -n1 xprintidle


              or:



              while sleep 1; do xprintidle; done;



            2. Check if disabling screensaver works (while running this script, xscreensave should not pop up)



                  #!/bin/bash

              while sleep 55
              do
              #xscreensaver-command -deactivate
              #xdg-screensaver reset
              xset s reset
              done



            3. Check for DBUS list for MPRIS player interface, example with VLC running:



                  gdbus call --session --dest org.freedesktop.DBus 
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }'


              Output:



                  org.mpris.MediaPlayer2.vlc
              org.mpris.MediaPlayer2.vlc.instance3939


              Or using dbus-send command



                  dbus-send --session 
              --dest=org.freedesktop.DBus
              --type=method_call
              --print-reply
              /org/freedesktop/DBus
              org.freedesktop.DBus.ListNames
              | grep org.mpris.MediaPlayer2.


              Output:



                  string "org.mpris.MediaPlayer2.vlc"
              string "org.mpris.MediaPlayer2.vlc.instance3939"



            References:





            • How to set up DBus query to get play state of VLC? original script by JB0x2D1

            • MPRIS D-Bus Interface Specification

            • Use qdbusviewer to check the correct destination name or to use other player you like.






            share|improve this answer















            You may try similar script to this one. Watch for player state through DBUS.



            I lower delay to 55 sec, work better with 1min screen saver idle time.





            • Example VLC:



              BTW, VLC in Ubuntu 14.04 has DBUS interface enabled by default. Where in Ubuntu 12.04 is not. Check it from:



              Tools → Preferences → Advanced (or All) → Interface → Control Interfaces → D-Bus control interface. (Apply then Restart VLC)





              1. Create a file heartbeat.sh in ~/Desktop/:



                #!/bin/bash

                while sleep 55
                do
                if [ "$(pgrep vlc)" != "" ]
                then
                state=$(bash -c 'gdbus call --session
                --dest org.mpris.MediaPlayer2.vlc
                --object-path /org/mpris/MediaPlayer2
                --method org.freedesktop.DBus.Properties.Get
                "org.mpris.MediaPlayer2.Player"
                "PlaybackStatus"')
                if [ "$state" = "(<'Playing'>,)" ]
                then
                #xscreensaver-command -deactivate
                xset s reset
                fi
                fi
                done


              2. Open terminal Ctrl+Alt+t



              3. Add run permissions:



                chmod +x ~/Desktop/heartbeat.sh



              4. Run script:



                ~/Desktop/heartbeat.sh


              5. Try VLC player.





            • For Gnome MPlayer (D-Bus enabled by default), use:



              "$(pgrep gnome-mplayer)" and
              --dest org.mpris.MediaPlayer2.gnome-mplayer




            • For (Totem) Videos player (D-Bus plugin disabled by default),



              Edit → Plugins → Check D-Bus service. (Restart totem)



              Use:



              "$(pgrep totem)" and
              --dest org.mpris.MediaPlayer2.totem




            • This is modified with to work with any player that provide MPRIS. It gets the list dynamically (drawback, it doesn't distinguish between audio only play and video play). The best way I think is to put manually the list of players you like:



              #!/bin/bash

              players_list=$(gdbus call --session --dest org.freedesktop.DBus
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

              while sleep 55
              do
              for player in $players_list
              do
              state=$(gdbus call --session
              --dest $player
              --object-path /org/mpris/MediaPlayer2
              --method org.freedesktop.DBus.Properties.Get
              "org.mpris.MediaPlayer2.Player"
              "PlaybackStatus")
              if [ "$state" = "(<'Playing'>,)" ]
              then
              echo $player $state send signal
              #xscreensaver-command -deactivate
              #use xset to work with all screensaver tools and avoid dimming display ...
              xset s reset
              break
              else
              echo $player $state
              fi
              done
              done



            Debug hints:





            1. Watch X idle time



              watch -n1 xprintidle


              or:



              while sleep 1; do xprintidle; done;



            2. Check if disabling screensaver works (while running this script, xscreensave should not pop up)



                  #!/bin/bash

              while sleep 55
              do
              #xscreensaver-command -deactivate
              #xdg-screensaver reset
              xset s reset
              done



            3. Check for DBUS list for MPRIS player interface, example with VLC running:



                  gdbus call --session --dest org.freedesktop.DBus 
              --object-path / --method org.freedesktop.DBus.ListNames |
              awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }'


              Output:



                  org.mpris.MediaPlayer2.vlc
              org.mpris.MediaPlayer2.vlc.instance3939


              Or using dbus-send command



                  dbus-send --session 
              --dest=org.freedesktop.DBus
              --type=method_call
              --print-reply
              /org/freedesktop/DBus
              org.freedesktop.DBus.ListNames
              | grep org.mpris.MediaPlayer2.


              Output:



                  string "org.mpris.MediaPlayer2.vlc"
              string "org.mpris.MediaPlayer2.vlc.instance3939"



            References:





            • How to set up DBus query to get play state of VLC? original script by JB0x2D1

            • MPRIS D-Bus Interface Specification

            • Use qdbusviewer to check the correct destination name or to use other player you like.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 18 '14 at 7:51

























            answered Apr 10 '14 at 20:35









            user.dzuser.dz

            35.3k1198179




            35.3k1198179













            • @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

              – user.dz
              Apr 13 '14 at 6:05











            • This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

              – Chris26284
              Apr 15 '14 at 20:37











            • @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

              – user.dz
              May 2 '14 at 8:07











            • I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

              – Chris26284
              May 25 '14 at 0:33











            • @Chris26284, I have updated it to use xset

              – user.dz
              Jun 17 '14 at 19:22



















            • @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

              – user.dz
              Apr 13 '14 at 6:05











            • This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

              – Chris26284
              Apr 15 '14 at 20:37











            • @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

              – user.dz
              May 2 '14 at 8:07











            • I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

              – Chris26284
              May 25 '14 at 0:33











            • @Chris26284, I have updated it to use xset

              – user.dz
              Jun 17 '14 at 19:22

















            @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

            – user.dz
            Apr 13 '14 at 6:05





            @Chris26284, I have updated answer. I confirmed, it works in 12.04 as I tested it in a VirtualBox. So did you get any error on terminal when you run the script?

            – user.dz
            Apr 13 '14 at 6:05













            This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

            – Chris26284
            Apr 15 '14 at 20:37





            This still doesn't work at all. I've tried both ways. I've deleted previous attempts and tried again from scratch. This does nothing.

            – Chris26284
            Apr 15 '14 at 20:37













            @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

            – user.dz
            May 2 '14 at 8:07





            @Chris26284, I feel difficult to debug or to expect the cause. Only if you have patient to do so. I will try to add some debugging hints

            – user.dz
            May 2 '14 at 8:07













            I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

            – Chris26284
            May 25 '14 at 0:33





            I recently updated my system to Ubuntu 14.04? Should the above fix work any better now?

            – Chris26284
            May 25 '14 at 0:33













            @Chris26284, I have updated it to use xset

            – user.dz
            Jun 17 '14 at 19:22





            @Chris26284, I have updated it to use xset

            – user.dz
            Jun 17 '14 at 19:22













            0














            For MPV, and mplayer, the heartbeat functionality is built in.



            1) Locate your mpv configuration file. locate mpv.conf



            2) Open it up. sudo nano /path/to/mpv.conf



            3) Add this line at the bottom. heartbeat-cmd="/usr/bin/xscreensaver-command -deactivate > /dev/null"



            4) Close, and save. Ctrl+X if using nano.



            Find out where to find your mpv.conf file here (configuration is identical on Arch Linux), https://wiki.archlinux.org/index.php/Mpv#Configuration




            If the environment variable XDG_CONFIG_HOME is not set, user configuration files will be read from the ~/.config/mpv directory. System-wide configuration files are read from the /etc/mpv directory.







            share|improve this answer




























              0














              For MPV, and mplayer, the heartbeat functionality is built in.



              1) Locate your mpv configuration file. locate mpv.conf



              2) Open it up. sudo nano /path/to/mpv.conf



              3) Add this line at the bottom. heartbeat-cmd="/usr/bin/xscreensaver-command -deactivate > /dev/null"



              4) Close, and save. Ctrl+X if using nano.



              Find out where to find your mpv.conf file here (configuration is identical on Arch Linux), https://wiki.archlinux.org/index.php/Mpv#Configuration




              If the environment variable XDG_CONFIG_HOME is not set, user configuration files will be read from the ~/.config/mpv directory. System-wide configuration files are read from the /etc/mpv directory.







              share|improve this answer


























                0












                0








                0







                For MPV, and mplayer, the heartbeat functionality is built in.



                1) Locate your mpv configuration file. locate mpv.conf



                2) Open it up. sudo nano /path/to/mpv.conf



                3) Add this line at the bottom. heartbeat-cmd="/usr/bin/xscreensaver-command -deactivate > /dev/null"



                4) Close, and save. Ctrl+X if using nano.



                Find out where to find your mpv.conf file here (configuration is identical on Arch Linux), https://wiki.archlinux.org/index.php/Mpv#Configuration




                If the environment variable XDG_CONFIG_HOME is not set, user configuration files will be read from the ~/.config/mpv directory. System-wide configuration files are read from the /etc/mpv directory.







                share|improve this answer













                For MPV, and mplayer, the heartbeat functionality is built in.



                1) Locate your mpv configuration file. locate mpv.conf



                2) Open it up. sudo nano /path/to/mpv.conf



                3) Add this line at the bottom. heartbeat-cmd="/usr/bin/xscreensaver-command -deactivate > /dev/null"



                4) Close, and save. Ctrl+X if using nano.



                Find out where to find your mpv.conf file here (configuration is identical on Arch Linux), https://wiki.archlinux.org/index.php/Mpv#Configuration




                If the environment variable XDG_CONFIG_HOME is not set, user configuration files will be read from the ~/.config/mpv directory. System-wide configuration files are read from the /etc/mpv directory.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 11 '15 at 17:12









                Mauro ColellaMauro Colella

                35635




                35635























                    0














                    Here is my own version from Chris' code:



                    #!/bin/bash
                    while sleep 55
                    do
                    players_list=$(gdbus call --session --dest org.freedesktop.DBus
                    --object-path / --method org.freedesktop.DBus.ListNames |
                    awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

                    for player in $players_list
                    do
                    state=$(gdbus call --session
                    --dest $player
                    --object-path /org/mpris/MediaPlayer2
                    --method org.freedesktop.DBus.Properties.Get
                    "org.mpris.MediaPlayer2.Player"
                    "PlaybackStatus")

                    fullscreen=$(gdbus call --session
                    --dest $player
                    --object-path /org/mpris/MediaPlayer2
                    --method org.freedesktop.DBus.Properties.Get
                    "org.mpris.MediaPlayer2"
                    "Fullscreen")

                    if [ "$state" = "(<'Playing'>,)" -a "$fullscreen" = "(<true>,)" ]
                    then
                    echo $player $state $fullscreen send signal
                    xscreensaver-command -deactivate
                    break
                    else
                    echo $player $state $fullscreen
                    fi
                    done
                    done


                    It checks at each iteration if the list of players has been changed.



                    It also deactivates the screensaver only if the player is fullscreen which is normally the case for video.



                    I just put this script in the autostart and don't bother anymore with xscreensaver while watching video.






                    share|improve this answer






























                      0














                      Here is my own version from Chris' code:



                      #!/bin/bash
                      while sleep 55
                      do
                      players_list=$(gdbus call --session --dest org.freedesktop.DBus
                      --object-path / --method org.freedesktop.DBus.ListNames |
                      awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

                      for player in $players_list
                      do
                      state=$(gdbus call --session
                      --dest $player
                      --object-path /org/mpris/MediaPlayer2
                      --method org.freedesktop.DBus.Properties.Get
                      "org.mpris.MediaPlayer2.Player"
                      "PlaybackStatus")

                      fullscreen=$(gdbus call --session
                      --dest $player
                      --object-path /org/mpris/MediaPlayer2
                      --method org.freedesktop.DBus.Properties.Get
                      "org.mpris.MediaPlayer2"
                      "Fullscreen")

                      if [ "$state" = "(<'Playing'>,)" -a "$fullscreen" = "(<true>,)" ]
                      then
                      echo $player $state $fullscreen send signal
                      xscreensaver-command -deactivate
                      break
                      else
                      echo $player $state $fullscreen
                      fi
                      done
                      done


                      It checks at each iteration if the list of players has been changed.



                      It also deactivates the screensaver only if the player is fullscreen which is normally the case for video.



                      I just put this script in the autostart and don't bother anymore with xscreensaver while watching video.






                      share|improve this answer




























                        0












                        0








                        0







                        Here is my own version from Chris' code:



                        #!/bin/bash
                        while sleep 55
                        do
                        players_list=$(gdbus call --session --dest org.freedesktop.DBus
                        --object-path / --method org.freedesktop.DBus.ListNames |
                        awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

                        for player in $players_list
                        do
                        state=$(gdbus call --session
                        --dest $player
                        --object-path /org/mpris/MediaPlayer2
                        --method org.freedesktop.DBus.Properties.Get
                        "org.mpris.MediaPlayer2.Player"
                        "PlaybackStatus")

                        fullscreen=$(gdbus call --session
                        --dest $player
                        --object-path /org/mpris/MediaPlayer2
                        --method org.freedesktop.DBus.Properties.Get
                        "org.mpris.MediaPlayer2"
                        "Fullscreen")

                        if [ "$state" = "(<'Playing'>,)" -a "$fullscreen" = "(<true>,)" ]
                        then
                        echo $player $state $fullscreen send signal
                        xscreensaver-command -deactivate
                        break
                        else
                        echo $player $state $fullscreen
                        fi
                        done
                        done


                        It checks at each iteration if the list of players has been changed.



                        It also deactivates the screensaver only if the player is fullscreen which is normally the case for video.



                        I just put this script in the autostart and don't bother anymore with xscreensaver while watching video.






                        share|improve this answer















                        Here is my own version from Chris' code:



                        #!/bin/bash
                        while sleep 55
                        do
                        players_list=$(gdbus call --session --dest org.freedesktop.DBus
                        --object-path / --method org.freedesktop.DBus.ListNames |
                        awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[[]()x27]/, ""); print $1; }')

                        for player in $players_list
                        do
                        state=$(gdbus call --session
                        --dest $player
                        --object-path /org/mpris/MediaPlayer2
                        --method org.freedesktop.DBus.Properties.Get
                        "org.mpris.MediaPlayer2.Player"
                        "PlaybackStatus")

                        fullscreen=$(gdbus call --session
                        --dest $player
                        --object-path /org/mpris/MediaPlayer2
                        --method org.freedesktop.DBus.Properties.Get
                        "org.mpris.MediaPlayer2"
                        "Fullscreen")

                        if [ "$state" = "(<'Playing'>,)" -a "$fullscreen" = "(<true>,)" ]
                        then
                        echo $player $state $fullscreen send signal
                        xscreensaver-command -deactivate
                        break
                        else
                        echo $player $state $fullscreen
                        fi
                        done
                        done


                        It checks at each iteration if the list of players has been changed.



                        It also deactivates the screensaver only if the player is fullscreen which is normally the case for video.



                        I just put this script in the autostart and don't bother anymore with xscreensaver while watching video.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 15 '17 at 15:19









                        derHugo

                        2,36921532




                        2,36921532










                        answered Dec 26 '14 at 11:49









                        sk3sk3

                        1




                        1























                            0














                            I noticed all the answers here seemed unnecessarily complex; you don't really need to do this based on a specific media player - all you need to do is detect if any audio is playing. I'm actually surprised this isn't a feature built into xscreensaver. Here's a super simple bash script:



                            #!/bin/bash

                            while true
                            do
                            state=$(pacmd list-sinks | grep -A 4 "*" | grep "state: " | cut -c 9-)
                            if [[ $state == SUSPENDED || $state == IDLE ]]
                            then
                            echo "State: $state. Not pausing screensaver."
                            sleep 2m
                            else
                            echo "State: $state. Pausing screensaver."
                            xscreensaver-command -deactivate > /dev/null
                            sleep 4m
                            fi
                            done





                            share|improve this answer






























                              0














                              I noticed all the answers here seemed unnecessarily complex; you don't really need to do this based on a specific media player - all you need to do is detect if any audio is playing. I'm actually surprised this isn't a feature built into xscreensaver. Here's a super simple bash script:



                              #!/bin/bash

                              while true
                              do
                              state=$(pacmd list-sinks | grep -A 4 "*" | grep "state: " | cut -c 9-)
                              if [[ $state == SUSPENDED || $state == IDLE ]]
                              then
                              echo "State: $state. Not pausing screensaver."
                              sleep 2m
                              else
                              echo "State: $state. Pausing screensaver."
                              xscreensaver-command -deactivate > /dev/null
                              sleep 4m
                              fi
                              done





                              share|improve this answer




























                                0












                                0








                                0







                                I noticed all the answers here seemed unnecessarily complex; you don't really need to do this based on a specific media player - all you need to do is detect if any audio is playing. I'm actually surprised this isn't a feature built into xscreensaver. Here's a super simple bash script:



                                #!/bin/bash

                                while true
                                do
                                state=$(pacmd list-sinks | grep -A 4 "*" | grep "state: " | cut -c 9-)
                                if [[ $state == SUSPENDED || $state == IDLE ]]
                                then
                                echo "State: $state. Not pausing screensaver."
                                sleep 2m
                                else
                                echo "State: $state. Pausing screensaver."
                                xscreensaver-command -deactivate > /dev/null
                                sleep 4m
                                fi
                                done





                                share|improve this answer















                                I noticed all the answers here seemed unnecessarily complex; you don't really need to do this based on a specific media player - all you need to do is detect if any audio is playing. I'm actually surprised this isn't a feature built into xscreensaver. Here's a super simple bash script:



                                #!/bin/bash

                                while true
                                do
                                state=$(pacmd list-sinks | grep -A 4 "*" | grep "state: " | cut -c 9-)
                                if [[ $state == SUSPENDED || $state == IDLE ]]
                                then
                                echo "State: $state. Not pausing screensaver."
                                sleep 2m
                                else
                                echo "State: $state. Pausing screensaver."
                                xscreensaver-command -deactivate > /dev/null
                                sleep 4m
                                fi
                                done






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Nov 15 '17 at 15:19









                                derHugo

                                2,36921532




                                2,36921532










                                answered Sep 9 '17 at 19:26









                                BenBen

                                1571317




                                1571317























                                    0














                                    This worked for me on Xubuntu 17.10 with xscreensaver



                                    #!/bin/bash

                                    while true; do
                                    sleep 10
                                    cat /proc/asound/card*/pcm*/sub*/status | grep RUNNING && xscreensaver-command -deactivate
                                    done





                                    share|improve this answer




























                                      0














                                      This worked for me on Xubuntu 17.10 with xscreensaver



                                      #!/bin/bash

                                      while true; do
                                      sleep 10
                                      cat /proc/asound/card*/pcm*/sub*/status | grep RUNNING && xscreensaver-command -deactivate
                                      done





                                      share|improve this answer


























                                        0












                                        0








                                        0







                                        This worked for me on Xubuntu 17.10 with xscreensaver



                                        #!/bin/bash

                                        while true; do
                                        sleep 10
                                        cat /proc/asound/card*/pcm*/sub*/status | grep RUNNING && xscreensaver-command -deactivate
                                        done





                                        share|improve this answer













                                        This worked for me on Xubuntu 17.10 with xscreensaver



                                        #!/bin/bash

                                        while true; do
                                        sleep 10
                                        cat /proc/asound/card*/pcm*/sub*/status | grep RUNNING && xscreensaver-command -deactivate
                                        done






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Dec 23 '17 at 8:16









                                        nmz787nmz787

                                        1265




                                        1265























                                            0














                                            This worked for me with Xubuntu 18.10 and with VLC, youtube videos, etc... wiithout the need to disable xscreensaver.
                                            Just add the following script when you system start:



                                            #!/bin/bash
                                            # enumerate all the attached screens
                                            displays=""
                                            while read id
                                            do
                                            displays="$displays $id"
                                            done< <(xvinfo | sed -n 's/^screen #([0-9]+)$/1/p')

                                            checkFullscreen()
                                            {

                                            # loop through every display looking for a fullscreen window
                                            for display in $displays
                                            do
                                            #get id of active window and clean output
                                            activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW`
                                            activ_win_id=${activ_win_id:40:9}

                                            # Check if Active Window (the foremost window) is in fullscreen state
                                            isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
                                            if [[ "$isActivWinFullscreen" == *NET_WM_STATE_FULLSCREEN* ]];then
                                            xscreensaver-command -deactivate
                                            fi
                                            done
                                            }

                                            while sleep $((30)); do
                                            checkFullscreen
                                            done

                                            exit 0





                                            share|improve this answer




























                                              0














                                              This worked for me with Xubuntu 18.10 and with VLC, youtube videos, etc... wiithout the need to disable xscreensaver.
                                              Just add the following script when you system start:



                                              #!/bin/bash
                                              # enumerate all the attached screens
                                              displays=""
                                              while read id
                                              do
                                              displays="$displays $id"
                                              done< <(xvinfo | sed -n 's/^screen #([0-9]+)$/1/p')

                                              checkFullscreen()
                                              {

                                              # loop through every display looking for a fullscreen window
                                              for display in $displays
                                              do
                                              #get id of active window and clean output
                                              activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW`
                                              activ_win_id=${activ_win_id:40:9}

                                              # Check if Active Window (the foremost window) is in fullscreen state
                                              isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
                                              if [[ "$isActivWinFullscreen" == *NET_WM_STATE_FULLSCREEN* ]];then
                                              xscreensaver-command -deactivate
                                              fi
                                              done
                                              }

                                              while sleep $((30)); do
                                              checkFullscreen
                                              done

                                              exit 0





                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                This worked for me with Xubuntu 18.10 and with VLC, youtube videos, etc... wiithout the need to disable xscreensaver.
                                                Just add the following script when you system start:



                                                #!/bin/bash
                                                # enumerate all the attached screens
                                                displays=""
                                                while read id
                                                do
                                                displays="$displays $id"
                                                done< <(xvinfo | sed -n 's/^screen #([0-9]+)$/1/p')

                                                checkFullscreen()
                                                {

                                                # loop through every display looking for a fullscreen window
                                                for display in $displays
                                                do
                                                #get id of active window and clean output
                                                activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW`
                                                activ_win_id=${activ_win_id:40:9}

                                                # Check if Active Window (the foremost window) is in fullscreen state
                                                isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
                                                if [[ "$isActivWinFullscreen" == *NET_WM_STATE_FULLSCREEN* ]];then
                                                xscreensaver-command -deactivate
                                                fi
                                                done
                                                }

                                                while sleep $((30)); do
                                                checkFullscreen
                                                done

                                                exit 0





                                                share|improve this answer













                                                This worked for me with Xubuntu 18.10 and with VLC, youtube videos, etc... wiithout the need to disable xscreensaver.
                                                Just add the following script when you system start:



                                                #!/bin/bash
                                                # enumerate all the attached screens
                                                displays=""
                                                while read id
                                                do
                                                displays="$displays $id"
                                                done< <(xvinfo | sed -n 's/^screen #([0-9]+)$/1/p')

                                                checkFullscreen()
                                                {

                                                # loop through every display looking for a fullscreen window
                                                for display in $displays
                                                do
                                                #get id of active window and clean output
                                                activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW`
                                                activ_win_id=${activ_win_id:40:9}

                                                # Check if Active Window (the foremost window) is in fullscreen state
                                                isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
                                                if [[ "$isActivWinFullscreen" == *NET_WM_STATE_FULLSCREEN* ]];then
                                                xscreensaver-command -deactivate
                                                fi
                                                done
                                                }

                                                while sleep $((30)); do
                                                checkFullscreen
                                                done

                                                exit 0






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Apr 6 at 21:29









                                                Alter LagosAlter Lagos

                                                6922823




                                                6922823






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Ask Ubuntu!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f445612%2fhow-do-i-stop-xscreensaver-during-movies-play%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Category:香港粉麵

                                                    List *all* the tuples!

                                                    Channel [V]