3

I have my nautilus directory bookmarks set up the way I want.

I don't want to accidentally "+ Other Locations" or accidentally drag and drop the bookmarks I already have, which seems to happen often.

Is there any way to "lock" the existing bookmarks in place (and get rid of the "+ Other Locations" link) until I decide I want to make changes and "unlock" its state?

Thanks!

Edit: Using Ubuntu version 18.04, screenshot attached below.

nautilus bookmarks screenshot

  • 1
    Please specify your Ubuntu version. And screenshot will be very useful too. – N0rbert May 23 '18 at 20:55
  • Ok, added this info above! – Macho May 24 '18 at 13:09
  • Hi @Macho just curious, did you try the answer / did you run into problems, did it work for you etc? – Jacob Vlijm May 28 '18 at 6:17
3

Ok, just a quick one for fun:

If you'd prefer not to fiddle with permissions, just run the script below in the background. Checking a text file once per five seconds adds zero to your system's burden, so no worries about that.

#!/usr/bin/env python3
import os
import time

home = os.environ["HOME"]
f = os.path.join(home, ".config/gtk-3.0/bookmarks")


text1 = open(f).read()


while True:
    time.sleep(5)
    text2 = open(f).read()
    if text2 != text1:
        open(f, "wt").write(text1)

How to use

  1. Copy the script below into an empty file, save it as fix_bookmarks.py
  2. Test-run it with the command:

    python3 /path/to/fix_bookmarks.py
    
  3. Try to add bookmarks, they will immediately (within 5 seconds) be reverted.

  4. If all works fine, ad it to Startup Applications.

Explantion

Once per 5 seconds, the script checks if the bookmarks file is still in exactly the same state as when you started the script. It will revert if not.

Toggle editing bookmarks

enter image description here

To toggle the ability to edit your bookmarks, copy the small script below, save it as toggle_bookmarks.sh in one and the same directory as fix_bookmarks.py, and add the first one to a shortcut, or to any other way to run the toggle script.

#!/bin/bash

dr=$(dirname "$0")
f=$dr'/fix_bookmarks.py'

if ! pgrep -f "$f"
then
  "$f" &
  notify-send -i 'bookmark-new-symbolic' 'Bookmarks' 'Editing disabled'
else 
  pkill -f "$f"
  notify-send -i 'bookmark-new-symbolic' 'Bookmarks' 'Editing enabled'
fi
  • 1
    Eh. Would it not be cheaper to set a watchdog on the file? – Rinzwind May 24 '18 at 13:42
  • I don't think so. This adds totally zero. Well, this is a watchdog :) (and it writes in 30 seconds :) ) – Jacob Vlijm May 24 '18 at 13:43
  • @JacobVlijm Quote the variables in shell scripts to avoid word splitting, aka things breaking because of spaces. Quoting isn't necessary in variable assignment though, because word splitting isn't performed in assignments. Also $(...) command substitution is preferred nowadays. – Sergiy Kolodyazhnyy May 24 '18 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.