Hiding drives on the desktop

Discussion in 'Mac Programming' started by macstatic, Apr 4, 2015.

  1. macstatic macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #1
    I've had success in hiding my drives from the Finder desktop using the script below, but for some reason it doesn't work any more. I upgraded from OSX 10.6.8 Snow Leopard to 10.9.5 Mavericks recently so could that have something to do with it? Does it need to be modified for Mavericks?

    Code:
    quit application "Finder"
    tell application "System Events" to ¬
    	set visible of disk "Backup clone" to false
    delay 1
    launch application "Finder"
     
  2. Bruno09 macrumors 68020

    Joined:
    Aug 24, 2013
    Location:
    Far from here
    #2
    Hi,

    you might use this :

    Code:
    sudo chflags hidden /Volumes/"Backup clone"; killall Finder
     
  3. ArtOfWarfare macrumors G3

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    You could download TinkerTool and see what that can do for you. I personally disable/remove the desktop entirely.
     
  4. Mark FX, Apr 5, 2015
    Last edited: Apr 5, 2015

    Mark FX macrumors regular

    Mark FX

    Joined:
    Nov 18, 2011
    Location:
    West Sussex, UK
    #4
    AppleScript has change a bit since Snow Leopard.
    As you've found out System Events doesn't do that anymore for some reason.

    Try this.

    Code:
    tell application "Finder" to eject disk "MyDiskName"
    
    This will raise an error if "MyDiskName" doesn't exist.

    So this would be better.

    Code:
    tell application "Finder"
        set diskNames to name of every disk as list -- Will only return visible Disks
        if diskNames contains "MyDiskName" then
            eject disk "MyDiskName"
        else
            return
        end if
    end tell
    
    Hope this helps.

    Regards Mark
     
  5. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #5
    just rename them with a leading .
    This way it will become a hidden folder in /Volumes/ and will not be shown on the desktop (by default ofcourse, as you can turn on show hidden folders)
     
  6. macstatic thread starter macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #6
    I'm beginning to think I first of all have a permissions issue.
    I'm able to hide/unhide certain drives with the same scripts, and some drives can be hidden/unhidden with the same scripts while logging in as the administrator.
    Since this is a bit off-topic I'll ask around for help on that subject and see what happens with the scripts.
     
  7. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #7
    You might try to run it through a shell command with administrator privileges like:
    Code:
    set command to "quit application \"Finder\"
    tell application \"System Events\" to set visible of disk \"Backup clone\" to false\n
    delay 1\n
    launch application \"Finder\""
    
              do shell script "osascript -e '" & command & "'" user name "<ADMINUSER HERE>" password "<ADMINPASS HERE>" with administrator privileges
    I'm not sure this will work, I did not test it. But it's a good shot ;-)
     
  8. macstatic thread starter macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #8
    I think it might have been a permissions issue as I'm able to enable and disable drive icon visibility for all my drives now, except my bootable backup clone, and all with the old Applescripts I had since my OSX 10.6 setup.

    If I turn my user account into an administrator (enable "Allow user to administer this computer" in the "Users & Groups" preferences) I can however hide/unhide the bootable backup drive as well. I'm pretty sure however that with Snow Leopard I could do that without being an administrator. Strange. Maybe the bootable backup drive is the culprit, with different permissions from before? If I do a Finder "Get info" on that drive it says:

    system: Read & write
    admin: Read & write
    everyone: read only

    And "Ignore ownership on this drive" is disabled.

    Does it sound like I'm having some sort of problems still, or is this the way it should work?
     
  9. jsavvy macrumors member

    jsavvy

    Joined:
    Aug 19, 2011
    #9
    I'm not running Mavericks anymore but Yosemite...everything you're wanting to do can be done through preferences in Yosemite so it may be worth a quick check to see if this is the case in Mavericks too.
     
  10. macstatic thread starter macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #10
    Which preference pane are you talking about? I can't find anything in Mavericks which allows you to change the visibility, but I have found out that Onyx allows for hiding drives (Utilities-Visibility). I'm going to try hiding drives this way instead of using the scripts and see if it solves my problems.
     

    Attached Files:

  11. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #11
    You can try the -o nobrowse option if you mount it manually.
     
  12. jsavvy macrumors member

    jsavvy

    Joined:
    Aug 19, 2011
    #12
    In Yosemite, the menu bar options for the Finder has a preferences section just for the Finder. Then, the first options are to show or hide different drives, etc. on the desktop. If you click on the sidebar option, you can choose what to show or hide in the sidebar of each Finder window as well.
     

    Attached Files:

  13. Partron22, Apr 13, 2015
    Last edited: Apr 13, 2015

    Partron22 macrumors 68020

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #13
    I had to rejigger my drive hiding Applescript some for Yosemite.
    The interface is deliberately a little clunky, so read the docs at the top of the script.
    It's working fine for me under 10.10.3
    The script TOGGLES drive visibility. Run it once to hide, and again to show.
    Sometimes it'll ask for your admin password.
    If it asks, and you don't know it, the script won't work.
    You can do evil things with this. Don't.
    Code:
    -- Drive Visibility Toggler
    -- BP 2010 - November 2014 (Yosemite tightened restrictions, so System Events won't set visible flag easily any more)
    -- Toggles the desktop visibility of an individual drive. This does NOT affect visibility in file Dialogs.
    -- Finder prefs for visibility are preserved, simply superceded by this lower level flag.
    -- Won't work on boot partition, or bootable partitions without either sudo or admin privileges.  (UNIX -> GetFileInfo SetFile)
    -- Using Admin privileges, it will sometimes ask for admin password. That's as it should be.
    
    -- If you use it on a network drive, visibility changes will affect all users. Don't be a jerk.
    -- Invisibility will survive unplugging drive and attaching it to another Mac.
    
    -- You must manually target the drive by inserting its name correctly in the next line of code.
    ------------------------------------------------------------------------------------
    ----------- user settable variables
    set drivename to "Ceres" -- **** Set this to the name of the drive you want to act on. ****
    ----------- end of user settable variables
    ------------------------------------------------------------------------------------
    
    
    set quoteddrivename to quoted form of drivename
    try
    	set attribs to (do shell script "GetFileInfo -a /Volumes/" & quoteddrivename) as text
    on error
    	beep (1)
    	return
    end try
    
    try
    	considering case
    		if attribs contains "v" then
    			do shell script "SetFile -a V /Volumes/" & quoteddrivename with administrator privileges
    		else
    			do shell script "SetFile -a v /Volumes/" & quoteddrivename with administrator privileges
    		end if
    	end considering
    on error
    	beep (1)
    	return
    end try
    do shell script "killall Finder" -- Restart the Finder to show changed visibility This is not necessary as long as I toggle the Finder's vis prefs.
    
     
  14. macstatic thread starter macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #14
    Yes, the toggle script appears to works nicely, but it seems running any of the scripts makes Time Machine act weird as it now backs up huge amounts of data even if I haven't created/download any new files, or even if I've just completed a backup.
    I'm only taking a wild guess here, but could they somehow change the status of the hidden drive so that Time Machine thinks there's new data to be added?

    The backup drive in question which I'm hiding has the following ownership:

    system: Read & write
    admin: Read & write
    everybody: Read only


    while another drive which I just formatted and used for a similar backup, but is an external drive (shouldn't make any difference, should it?) has these ownerships:

    system: Read & write
    wheel Read & write
    everybody: Read only

    ----------

    Yes, this is a freature I've seen in every OSX version AFAIK, but it only allows you to show or hide ALL internal or ALL external drives, which is not what I want.
    Since this is a backup clone I just want to hide it everywhere (in The Finder, in the Finder windows sidebar and in open/save dialogs) because I don't want to accidently save my files to the backup instead of the source drive(s). Chronosync however must be able to detect the drive as available and mounted for doing its automated backups.
     
  15. EconTech macrumors newbie

    Joined:
    Apr 17, 2012
    #15
    Have you considered keeping the volume unmounted and just have ChronoSync mount it for you when it's time to backup? It can then unmount it when finished.
     
  16. briloronmacrumo macrumors 6502

    briloronmacrumo

    Joined:
    Jan 25, 2008
    Location:
    USA
    #16
    The volume can be hidden via Terminal commands...

    Discovered this years ago and I don't remember the source. Here is a copy of the instructions:

    First open Terminal and enter “diskutil list”. In the identifier, the drive should be listed as something along the lines of “disk0s3″. Now type “diskutil info (whatever your drive is listed as)”. For me: diskutil info disk0s3. That will list a whole bunch of information about the drive. Look for where it says “Volume UUID” and copy the string.

    Next, enter “sudo pico /etc/fstab”. Terminal will open an fstab file. This file will let you tell your Mac not to boot a drive. The file should be empty.

    Enter the following:
    UUID= (Insert your drive’s exact UUID here) none ntfs ro,noauto 0 0
    For FAT32 formatted drives, replace “ntfs” with “msdos”. Exit and save with ctrl+x (it will prompt you to save the changes).
    If an OSX volume enter "hfs" instead of ntfs. Also, 'ro' can be 'rw" ( read/write ). This is what I did for the external backup hard drive.
    Exit Terminal, restart, and the drive should not show up. You can still boot it as a Virtual Machine, and if you need to mount it to access anything from within Mac OS X, just go to Disk Utility, click the grayed-out Boot Camp volume name and mount it.
    This is not some crazy new idea or anything, it’s the standard way to prevent auto-mounting through OS X’s Unix foundations, but it can be hard to find.
     
  17. macstatic thread starter macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #17
    That's a good idea which I hadn't considered.
    I've now created and edited the Chronosync mount drive script, as well as the Chronosync drive unmount Applescript.
    The only problem is that I'm asked for the admin password each time. Is there a way to bypass this? Or are my backup drive's permissions incorrect and causing this?:

    system: read & write
    admin: read & write
    everyone: read only
     
  18. EconTech macrumors newbie

    Joined:
    Apr 17, 2012
    #18
    If you're using ChronoSync 4.6, you don't need those scripts anymore. In "Setup", just click "Options" for the target volume and chose to mount the volume before the sync then unmount it when it's done. This is actually a common use pattern.

    Another thing you may want to do is blacklist the volume from Spotlight indexing, which can be done over in the Spotlight->Privacy system pref pane. That way Spotlight doesn't kick in when that volume gets mounted. If this is a pure backup volume, you don't need it. You can always re-enable Spotlight in the future if you ever find yourself in need of searching that volume.
     
  19. loby, May 1, 2015
    Last edited: May 1, 2015

    loby macrumors 6502a

    loby

    Joined:
    Jul 1, 2010
    #19
    I am glad someone asked this question and hopefully someone please can assist. Tried the above thread entries, but it would not eject my partition.

    I am trying to unmount a partition. I have multiple OS X's on a system and need to protect it when another partition is open. Tried using Automator, but would not eject a second partition.

    Can anyone help me with the script? I am working with Snow Leopard and Mavericks? As stated above, the script will be different on Snow Leopard and Mavericks.

    Thanks for any help!
     
  20. loby, May 1, 2015
    Last edited by a moderator: May 1, 2015

    loby macrumors 6502a

    loby

    Joined:
    Jul 1, 2010
    #20
    Found it..

    this worked:

    Code:
    set volname to "<DISKNAME>" -- # name of target volume  
    set p to (POSIX path of (volname & ":" as alias))'s text 1 thru -2
    set sh to "diskutil umount " & quoted form of p & " &> /dev/null &"
    do shell script sh
    Just put your disk or partition name where it says in the script: <DSKNAME> you are set. Will unmount the disk or partition.
     
  21. macstatic, May 6, 2015
    Last edited: May 6, 2015

    macstatic thread starter macrumors 65816

    macstatic

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #21
    Thanks -didn't know about that feature.
    I suppose with Containers containing multiple documents you just tell the first document to mount the drive and the last document to unmount it?


    Good call!
    Another issue I find with a duplicate drive on my system is that in some apps (i.e. Lightroom as far as I recall) I'm asked which supporting app to open a certain file, and among the list of apps, each of them are presented twice (one identical app from each drive).
    Unmounting the backup drive should certainly help, but since I have Chronosync back up fairly often I'm wondering if there's a way to hide it while backing up as well so these things don't happen?

    PS: how can I find out the cause of Chronosync errors? I've checked the log, but "ERROR: 'Daily backup HD' will be attampted again on 05/05/2015 11:50:00" really isn't all that helpful.
     
  22. EconTech macrumors newbie

    Joined:
    Apr 17, 2012
    #22
    That's one way - and probably what I would do.
    Or you could go back to the pre- and post- sync scripts attached to the container.

    Unfortunately, I don't know a solution for that. If there's a way to get Finder to stop scanning all mounted volumes for executable apps, I'm sure someone around here knows it. Perhaps blacklisting Spotlight on that volume will help, though I'm sure you'd need to reboot or at least restart Finder.

    That looks like a scheduler error and that you have "Retry on errors" enabled. Have you looked inside the specific sync document's log to see if it provides more details? (Command-L with the sync document open)
     

Share This Page