11

If I have dolphin open and I'm working in the terminal or on Windows files might be moved or added. How would I go about to make sure it updates the status of a directory of real time?

Presently I cannot even use back to update and constantly have to reopen dolphin, verry annoying

6 Answers6

6

The way in order to refresh Dolphin is to press F5. However, this would be manual.

In order to continuously refresh, an automatic solution, create a bash script that runs on boot. This bash script should press F5 every five seconds if Dolphin is open. Create a file named dolphin-update in /usr/local/bin with the following contents:

#!/bin/bash
while true; do
    PID=$(pgrep "dolphin")
    if [ "$?" -ne "0" ]; then
        xdotool key 'F5'
    fi
    sleep 5
done

You may need to first create it as root and then change the owner to your user:

sudo chown username:username /usr/local/bin/dolphin-update 

Ensure that it has executable permissions:

chmod +x /usr/local/bin/dolphin-update

Now we need that to run on boot. To do that run sudo crontab -e and add the following line to the end of the file:

@reboot /usr/local/bin/dolphin-update

This script will run on boot.

You should now have a continuously refreshing Dolphin!

There are some caveats to this script.

  • If you open Dolphin, go to another application where F5 triggers something, (eg Chromium refreshes the page), the script will still run and be a constant annoyance. Solution: Close Dolphin when not actively using it.
  • As a cron job is used, if your computer crashes, the script will not run on boot. However this is a problem with cron not the script.

What the script means, line by line:

  • #!/bin/bash - shebang to run with bash
  • while true; do - run continuously
  • PID=$(pgrep "dolphin") - find the process ID of a dolphin instance. This is purely there to check whether there is even a instance of Dolphin running.
  • if [ "$?" -ne "0" ]; then - check the result of whether there is a Dolphin instance running. If there is, then ...
  • xdotool key 'F5' - press F5
  • fi - end the if block
  • sleep 5 - wait 5 seconds before repeating the process
  • done - end the while block
fosslinux
  • 3,881
4

This seems to be a bug still active in Kubuntu 18.04, where Dolphin would not always automatically refresh and show instantly changes made by another program, in which case manual refresh is needed. F5 seems to work fine for this purpose now.

1

xdotool can send F5 key to dolphin on mouse-enter event or whenever it's window gets focus.

These commands run indefinetely so you can set one of them to run on boot.

Finds the window with class dolphin and sends the F5 whenever mouse pointer enters window:

xdotool search --onlyvisible --class dolphin  behave %@ mouse-enter key F5

Finds the window with class dolphin and sends the F5 whenever dolphin gets focus:

xdotool search --onlyvisible --class dolphin  behave %@ focus key F5
1

Next script uses xdotool to send F5 key to reset dolphin window whenever it has focus. Save it, make it executive and run it on boot.


#!/bin/bash
     # indefinite loop
     while  : ; do
         # gets root window property _NET_ACTIVE_WINDOW
         WIN=($(xprop -root _NET_ACTIVE_WINDOW))

         # extracts window id (base seven)
         WIN="${WIN[4]%%","*}"

         WIN="$(printf "%s\n" ${WIN})"  # bypass weird array bug

          # Decimal window id of dolphin
          WindowID="$(xdotool search --class "dolphin" 2>/dev/null | tail -1)"

          # Convert dolphin's win id to base seven
          WindowIDbSeven=$(printf "0x%07x" ${WindowID})

         # test if an acive window id mathes with the dolphin's window id
         if [[ "${WIN}" == "${WindowIDbSeven}" ]]; then
             # sends F5 to dolphin's window id
             xdotool key --clearmodifiers "$WindowIDbSeven" F5
         fi

          # clears array
          WIN=()

         sleep 5
     done
1

OP's original question is almost 5 years old. There is a master bug posted in 2009 with 15 duplicate bugs pointing to it. The bug fix appeared in Debian (comment # 58) after OP's question was posted.

The report that this bug is still happening in 2018 by a new bug report is a little misleading because the user that filed the report (Jeremy9856) has posted a dozen comments trying different solutions:

  • updated the number of allowed kernel inotify watches
  • disabling tlp which puts drives to sleep
  • do mkdir / rmdir several time to trigger the problem
  • Another user (comment #10) tested a one-liner and states the problem doesn't exist while true ; do mkdir abc ; sleep 1 ; rmdir abc ; sleep 1 ; done
  • when there is an accent in the path (eg. /home/jeremy/Téléchargements/Séries)

The last comment by Jeremy9586 states:

Well I removed the symlinks of the folders inside /home (Desktop, Downloads, etc...) that pointed to /media/Data and used kde settings (in applications) to change the places of these folders and I didn't had the problem for about a week !

So can it be related to the symlinks ?


Summary

The bug the OP had was first reported in 2009 and solved in 2013.

The bug the new bounty points to appears to have nothing to do with refreshing file list in general and need to press F5. The bug was caused by symbolic links between /home and /media/home.

1

I agree this is a problem with Dolphin. I don't use it, but was testing some bash scripts I wrote on a KDE VM and discovered that although Dolphin does real time updating when in the home folder, it doesn't do it when on /dev/shm. I found your question here and upvoted, because this still needs to be answered.

What I resorted to using in my script is: xdotool key 'F5'

Which worked for my script, but isn't exactly real time. My script generates a bunch of files and you can't see it happening, but as soon as done, it "presses" 'F5' and the files are visible.