Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #/home/clockworkpc/Documents/bin/natty_tweaks.py
- # Released under a GPLv3 Licence by Clockwork PC 2011
- #
- # www.clockworkpc.com.au
- #
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- # This script covers two operations:
- # (1) Moving the main home folders to /media/DATA/Users/Dropbox so that data on Ubuntu can be shared with Mac seamlessly
- # (2) Apply a variety of tweaks to make Unity more functional
- import os
- import time
- home = os.getenv("HOME")+'/'
- user_dirs = home+'.config/user-dirs.dirs'
- gtk_bookmarks = home+'.gtk-bookmarks'
- data_partition = '/media/DATA/Users/Dropbox/' #Please make sure this is where you want to put your Documents, Downloads, Music Pictures, and Videos.
- #NOTE: I DO NOT move the Desktop folder, because it seems to cause problems -- not to mention sharing your desktop with another OS can get messy, especially if it's a retarded one like OSX on Windows, which saves EVERYTHING to the Desktop.
- #Copy the contents of the existing user folders into the Dropbox folder on the DATA partition. Not strictly necessary if you run this on a vanilla installation, but still worthwhile.
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Documents /media/DATA/Users/Dropbox/")
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Downloads /media/DATA/Users/Dropbox/")
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Music /media/DATA/Users/Dropbox/")
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Pictures /media/DATA/Users/Dropbox/")
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Videos /media/DATA/Users/Dropbox/")
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Templates /media/DATA/Users/Dropbox/")
- os.system("cp --recursive --no-clobber --dereference --verbose $HOME/Public /media/DATA/Users/Dropbox/")
- print "The key directories are as follows:"
- print home
- print user_dirs
- print gtk_bookmarks
- print data_partition
- time.sleep(3)
- print """
- You have 5 seconds to press ctrl+C to abort this operation if something is amiss.
- """
- time.sleep(5)
- #Back up the User Directories list in case all hell breaks loose.
- os.system("cp $HOME/.config/user-dirs.dirs $HOME/.config/user-dirs.dirs.$(date +%F_%A_at_%H:%M:%S).backup ")
- #Over-write the User Directories listing in ~/.config/user-dirs.dirs with the new location, presumably on the data partition
- f=open(user_dirs,w)
- f.write('''
- XDG_PUBLICSHARE_DIR="/media/DATA/Users/Dropbox/Public"
- XDG_DOWNLOAD_DIR="/media/DATA/Users/Dropbox/Downloads"
- XDG_MUSIC_DIR="/media/DATA/Users/Dropbox/Music"
- XDG_VIDEOS_DIR="/media/DATA/Users/Dropbox/Videos"
- XDG_DESKTOP_DIR="$HOME/Desktop"
- XDG_DOCUMENTS_DIR="/media/DATA/Users/Dropbox/Documents"
- XDG_TEMPLATES_DIR="/media/DATA/Users/Dropbox/Templates"
- XDG_PICTURES_DIR="/media/DATA/Users/Dropbox/Pictures"
- ''')
- f.close()
- #Back up the GTK Bookmarks in case all hell breaks loose.
- os.system("cp $HOME/.gtk-bookmarks $HOME/gtk-bookmarks.$(date +%F_%A_at_%H:%M:%S).backup")
- #Over-write the GTK Bookmark (~/.gtk-bookmarks) with the new location, presumably on the data partition
- g=open(gtk_bookmarks)
- g.write('''
- file:///media/DATA/Users/Dropbox/Documents
- file:///media/DATA/Users/Dropbox/Music
- file:///media/DATA/Users/Dropbox/Pictures
- file:///media/DATA/Users/Dropbox/Videos
- file:///media/DATA/Users/Dropbox/Downloads
- file:///media/DATA/Websites
- file:///media/DATA/Screenshots
- file:///media/DATA/ISO
- ''')
- g.close()
- #Delete the existing User folders so that they can be replaced with symbolic links
- os.system("rm -rv $HOME/Documents")
- os.system("rm -rv $HOME/Music")
- os.system("rm -rv $HOME/Pictures")
- os.system("rm -rv $HOME/Videos")
- os.system("rm -rv $HOME/Downloads")
- os.system("rm -rv $HOME/Public")
- os.system("rm -rv $HOME/Templates")
- # Replace newly deleted User folders with symbolic links to the folders in your specified location, presumably at /media/DATA/Users/Dropbox
- os.system(" $HOME && ln -s /media/DATA/Documents")
- os.system(" $HOME && ln -s /media/DATA/Downloads ")
- os.system(" $HOME && ln -s /media/DATA/Music")
- os.system(" $HOME && ln -s /media/DATA/Pictures")
- os.system(" $HOME && ln -s /media/DATA/Videos")
- os.system(" $HOME && ln -s /media/DATA/Public")
- os.system(" $HOME && ln -s /media/DATA/Templates")
- ### UNITY TWEAKS (Hooray!)
- #!/usr/bin/python
- #/home/clockworkpc/Documents/bin/test_unity_tweaks.py
- # Released under a GPLv3 Licence by Clockwork PC 2011
- #
- # www.clockworkpc.com.au
- #
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- import os
- import fileinput
- home=os.getenv("HOME")+"/"
- # Home Folders Quicklist
- os.system("cp /usr/share/applications/nautilus-home.desktop ~/.local/share/applications")
- nautilus_home=home+".local/share/applications/nautilus-home.desktop"
- f=open(nautilus_home, "w")
- f.write(''''[Desktop Entry]
- Name=Home Folder
- Comment=Open your personal folder
- TryExec=nautilus
- Exec=nautilus --no-desktop
- Icon=user-home
- Terminal=false
- StartupNotify=true
- Type=Application
- Categories=GNOME;GTK;Core;
- OnlyShowIn=GNOME;Unity;
- X-GNOME-Bugzilla-Bugzilla=GNOME
- X-GNOME-Bugzilla-Product=nautilus
- X-GNOME-Bugzilla-Component=general
- X-Ubuntu-Gettext-Domain=nautilus
- X-Ayatana-Desktop-Shortcuts=Videos;Documents;Music;Pictures;Downloads
- [Videos Shortcut Group]
- Name=Videos
- Exec=nautilus Videos
- TargetEnvironment=Unity
- [Documents Shortcut Group]
- Name=Documents
- Exec=nautilus Documents
- TargetEnvironment=Unity
- [Music Shortcut Group]
- Name=Music
- Exec=nautilus Music
- TargetEnvironment=Unity
- [Pictures Shortcut Group]
- Name=Pictures
- Exec=nautilus Pictures
- TargetEnvironment=Unity
- [Downloads Shortcut Group]
- Name=Downloads
- Exec=nautilus Downloads
- TargetEnvironment=Unity
- ''')
- f.close()
- # Ubuntu Software Centre Quicklist
- os.system("cp /usr/share/applications/ubuntu-software-center.desktop ~/.local/share/applications/")
- usc = home+".local/share/applications/ubuntu-software-center.desktop"
- g = open(usc, "w")
- g.write(''''X-Ayatana-Desktop-Shortcuts=SoftwareProperties;SoftwareSources;
- [SoftwareProperties Shortcut Group]
- Name=Update Manager
- Exec=update-manager -c %u
- TargetEnvironment=Unity
- [SoftwareSources Shortcut Group]
- Name=Add/Edit PPAs
- Exec=gksu software-properties-gtk
- TargetEnvironment=Unity
- ''')
- g.close()
- # Chromium Quicklist
- os.system ("cp /usr/share/applications/chromium-browser.desktop ~/.local/share/applications")
- chromium = home+".local/share/applications/chromium-browser.desktop"
- h=open(chromium, "w")
- h.write('''X-Ayatana-Desktop-Shortcuts=NewWindow;Incognito;
- [NewWindow Shortcut Group]
- Name=New Window
- Exec=chromium-browser
- TargetEnvironment=Unity
- [Incognito Shortcut Group]
- Name=New incognito window
- Exec=chromium-browser --incognito
- TargetEnvironment=Unity
- ''')
- h.close()
- # Terminal Quicklist
- import re
- os.system ("cp /usr/share/applications/gnome-terminal.desktop ~/.local/share/applications")
- gt=home+".local/share/applications/gnome-terminal.desktop"
- x = fileinput.input(gt, inplace=1)
- for line in x:
- line = line.replace("OnlyShowIn=GNOME;", "OnlyShowIn=GNOME;Unity;")
- print line,
- x.close()
- k=open(gt, "a")
- k.write('''X-Ayatana-Desktop-Shortcuts=NewWindow;NewTab;Top;Root;
- [NewWindow Shortcut Group]
- Name=New Window
- Exec=gnome-terminal --window
- TargetEnvironment=Unity
- [NewTab Shortcut Group]
- Name=New Tab
- Exec=gnome-terminal --tab
- TargetEnvironment=Unity
- [Root Shortcut Group]
- Name=Root Terminal
- Exec=gksudo gnome-terminal
- TargetEnvironment=Unity
- [Top Shortcut Group]
- Name=Top
- Exec=gnome-terminal --command top
- TargetEnvironment=Unity
- ''')
- k.close()
- # LibreOffice Quicklist
- os.system('cp /usr/share/applications/libreoffice-startcenter.desktop ~/.local/share/applications')
- LibreOffice = home+"/.local/share/applications/libreoffice-startcenter.desktop"
- l=open(LibreOffice, "w")
- l.write('''##Start of shortcut menu
- ##List of shortcuts
- X-Ayatana-Desktop-Shortcuts=Writer;Impress;Calc;Math;Draw
- ##Define Shortcuts
- [Writer Shortcut Group]
- Name=Writer
- Exec=libreoffice -writer %U
- TargetEnvironment=Unity
- [Impress Shortcut Group]
- Name=Impress
- Exec=libreoffice -impress %U
- TargetEnvironment=Unity
- [Calc Shortcut Group]
- Name=Calc
- Exec=libreoffice -calc %U
- TargetEnvironment=Unity
- [Math Shortcut Group]
- Name=Math
- Exec=libreoffice -math %U
- TargetEnvironment=Unity
- [Draw Shortcut Group]
- Name=Draw
- Exec=libreoffice -draw %U
- TargetEnvironment=Unity
- ##End of shortcut menu
- ''')
- l.close()
- # Apply the changes
- os.system("unity --replace")
- os.system("gedit ~/.local/share/applications/nautilus-home.desktop ~/.local/share/applications/ubuntu-software-center.desktop ~/.local/share/applications/chromium-browser.desktop ~/.local/share/applications/gnome-terminal.desktop ~/.local/share/applications/libreoffice-startcenter.desktop")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement