What does a bill like PIPA/SOPA mean to our shareable world? At the TED offices, Clay Shirky delivers a proper manifesto — a call to defend our freedom to create, discuss, link and share, rather than passively consume.

Download video. This is the most compelling and well-presented treatise I have yet seen on the subject.

If you have a website I encourage you to add the Hello Bar to your site to help raise awareness and show your opposition to PIPA.

Mac OSX 10.7: (Un)Locking the Dock

The Dock in Mac OSX is attractive, functional, and fun. I have used similar docking/launching systems for years in Linux (Docky, WBar, Cairo, AWN) and found them to enhance my productivity while providing a bit of eye-candy. Thus, I have looked forward to the Dock in OSX, but have been disappointed to find a lack of configuration options.

Enter AppleScript.

I won’t go into explaining AppleScript in detail or even touch on more than the basics of how to work with it in OSX. There are plenty of good tutorials for that. What I will do is share six scripts I have put together to provide a decent enhancement to the existing options. The following scripts will allow you to:

Add “Spacers” to the Applications section (left side) of the Dock to aid in organization.
Add “Spacers” to the Documents section (right side) of the Dock to aid in organization.
Save a backup of the current Dock configuration.
Restore the Dock configuration to the saved state using the Save from script
Lock the Dock to prevent accidental removal or shifting of Icons.
Unlock the Dock to allow modification.

The scripts are very simple, but illustrate the power of scripting on *nix systems. AppleScript can execute shell commands via do shell script, and AppleScripts can be executed from the shell and much more. These scripts focus on executing shell commands from easily executable scripts.

DockAppSpace

do shell script "defaults write com.apple.dock persistent-apps -array-add
      '{tile-data={}; tile-type=\"spacer-tile\";}' && killall Dock"

DockOtherSpace

do shell script "defaults write com.apple.dock persistent-others -array-add
      '{tile-data={}; tile-type=\"spacer-tile\";}' && killall Dock"

DockSave

do shell script "cp $HOME/Library/Preferences/com.apple.dock.plist $HOME/
      Library/Preferences/com.apple.dock_.plist"

DockRestore

do shell script "cp $HOME/Library/Preferences/com.apple.dock_.plist $HOME/
      Library/Preferences/com.apple.dock.plist; killall Dock"

DockLock

do shell script "defaults write com.apple.dock contents-immutable -bool Yes;
      killall Dock"

DockUnlock

do shell script "defaults write com.apple.dock contents-immutable -bool No;
      killall Dock"

You will notice that the first two scripts end with ‘&& killall Dock’ and the last four end with ‘; killall Dock’. I have provided two examples of legal syntaxes for chaining commands in the bash shell. Both the double-ampersand (&&) and the semicolon (;) essentially mean “and then do.”

Command1 && Command2 and Command1; Command2

are equivalent and both mean execute Command1 and then execute Command2.

To use these scripts, open the AppleScript Editor. You can launch it from Applications/Utilities, or use Command + Space to open Spotlight and type Apple and it should be the Top Hit.

First, let’s save your current Dock configuration so you can restore it if you need to. Copy and Paste the DockSave script into the Editor. Save the file (Cmd + S) as DockSave.scpt and then Run (Cmd + R) the script. I made a Scripts folder in my home directory. Save it wherever you like.

Copy and Paste the DockAppSpace script into the Editor. Save the file as DockAppSpace and then Run the script. You should now have a space or gap between two icons on your Dock. This Spacer can be manipulated the same as the other icons. You can move it around, drag it off of the Dock to remove it, or whatever. Running the script multiple times creates multiple spacers.

The DockOtherSpace script does the same thing for the Documents (right) side of the Dock.

As you can see in the screenshot above, I have my icons organized into what I consider logical groups. At the far left are administration utilities such as Finder, System Preferences, Terminal, and Disk Utility client. Next are Internet apps like web browsers, mail, and FTP client. Then productivity apps like iWork, Text Editor, XCode, and Grab. Fourth are multimedia apps. At the far right are virtualization and remote access apps.

I find that this goes a long way towards helping me organize and make better use of the Dock. The DockRestore script will (surprise…) restore your Dock to whatever state it was in when you last ran the DockSave script.

The DockLock and DockUnlock scripts lock and unlock the Dock respectively to deny or allow changes in the Dock state. This is what really got me started because I kept accidentally dragging Icons off of the Dock and “poofing” them away.

Now comes the fun part. You saved the scripts as .scpt files. This is fine, but by changing the File Format in the drop-down box you can save the script as an Application with a .app extension.

Now the App can be added to your Applications Folder and run like any other app. This means you can, if you want, add it to the dock or desktop and execute is as an application. Double-clicking an .scpt file will open it in the AppleScript Editor, which is probably not what you want. Using the .app is likely preferred.

If you’d like to change the icon for your app from the script icon to something else, you can. The file format for icons in OSX is .icns. There is a nifty little free app called img2icns which lets you drag-and- drop images to the window and convert them to .icns in a snap by clicking the .icns icon.

Once you have created an .icns, go to where you saved your .app file and Ctrl + click it. From the context menu select “Show Package Contents”. Inside the resulting Contents folder are a.plist file (preferences), PkgInfo file, a MacOSX folder, and a Resources folder. Inside the Resource folder is an applet.icns. Replace this with your own .icns file. I renamed my icon applet.icns. It may not be needed.

It appears that Finder is notoriously bad at refreshing icons, so you have a couple of options if your new icon doesn’t show up.
1. Open Terminal and execute ‘killall Finder’ (no quotes). Finder will die and immediately resurrect

itself, at which point the icon cache will be reloaded.
2. Install or reproduce the tiny AppleScript app by Samuel Svensson called Refresh Finder which is discussed here.

While it is nice to be able to have some control over my own machine, the clear importance to administrators is a ‘window’ into managing the Mac OSX environment with AppleScripts. A script like DockLock, when run as root, would prevent unprivileged users from removing icons from the Dock. Similarly, the .plist files found in /Library/Preferences afford control over System preferences, but that is for another time.

Download PDF: MacAttack – (Un)Locking the Dock

TeamViewer is a great desktop sharing and remote control solution. Available for Linux, Mac, and Windows, TeamViewer offers two-way sharing, unattended access, file transfer, chat, voip and more. Setup is simple and it works great.

I have used the free version for simple operations like remotely helping a friend configure or install something on their computer Linux to Linux, Windows to Windows, and cross-platform. Now the usefulness of TeamViewer increases with the release of the free TeamViewer App for Android.


Continue reading »

Following up on my previous post about adding a Computer item to the nautilus Home launcher in Unity, let’s look at adding shortcuts to web pages in the Firefox launcher.

First, copy the firefox.desktop file from /usr/share/applications:

cp /usr/share/applications/firefox.desktop ~/.local/share/applications

Now open the file in a text editor, such as gedit:

gedit ~/.local/share/applications/firefox.desktop

You should see something like this (I edited out the long list of languages):

[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;
StartupWMClass=Firefox
StartupNotify=true
X-Ayatana-Desktop-Shortcuts=NewWindow;

[NewWindow Shortcut Group]
Name=Open a New Window
Exec=firefox -new-window about:blank
TargetEnvironment=Unity

Add names for the shortcuts to the end of this line:

X-Ayatana-Desktop-Shortcuts=NewWindow;

Such as:

X-Ayatana-Desktop-Shortcuts=NewWindow;TweakBlog;

Continue reading »

I recently upraded to Ubuntu 11.04. I wanted to hate the Unity interface…really I did. I tried, but I actually find it pretty cool…now that I can customize it.

First, a screenshot of my desktop:

The wallpaper can be found here:Wallpaper
and the icon set here:Icons

What can I say? i like monochrome…it matches everything!

I wanted to add an entry to the Unity Launcher Home / File Browser icon which would give me this:

Computer

The Unity Launcher items are configured through standard .desktop files. These files originate in /usr/share/applications. The customize them, copy the file you want, such as nautilus-computer.desktop, to ~/.local/share/applications with this command:

cp /usr/share/applications/nautilus-computer.desktop ~/.local/share/applications/

Now open the file at ~/.local/share/applications/nautilus-computer.desktop with an editor like gedit:

gedit ~/.local/share/applications/nautilus-computer.desktop

You should see something like this:

[Desktop Entry]
Name=Computer
Comment=Browse all local and remote disks and folders accessible from this computer
TryExec=nautilus
Exec=nautilus --no-desktop computer:
Icon=computer
Terminal=false
StartupNotify=true
Type=Application
Categories=GNOME;GTK;Core;
OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=nautilus
X-GNOME-Bugzilla-Component=general
X-GNOME-Bugzilla-Version=2.32.2
X-Ubuntu-Gettext-Domain=nautilus

Continue reading »

I recently got a book written by Johnathan Stark called, “Building Android Apps with HTML, CSS, and JavaScript.” This nifty little book goes through the process of creating “Android Apps” using only web scripting skills.

The basic idea is to use javascript and css to provide functionality and style to make your web site/ web app emulate the typical Android behavior and tailor the display to the mobile device. While this may (or may not) seem very useful, there’s more to the story.

The book also goes into detail describing how to launch your “app” from the home screen, store data locally on the phone, and operate in offline mode. Further, the author demonstrates the use of an open source project called PhoneGap to allow your web app to access the device hardware and features such as geolocation, accelerometer, sound, and vibration.

In a nutshell, PhoneGap works as a “wrapper” by abstracting the relevant API’s for iPhone, Android, BlackBerry, Palm, Symbian, and Windows Mobile, and producing an native-compatible app for the target platform…without writing platform-specific code.

It’s a pretty neat concept that allows for a great deal of flexibility and “cross-platform” exposure for a web app.

Description

If you know HTML, CSS, and JavaScript, you already have the tools you need to develop Android applications. This hands-on book shows you how to use these open source web standards to design and build apps that can be adapted for any Android device — without having to use Java.

You’ll learn how to create an Android-friendly web app on the platform of your choice, and then convert it to a native Android app with the free PhoneGap framework. Discover why device-agnostic mobile apps are the wave of the future, and start building apps that offer greater flexibility and a broader reach.

* Learn the basics for making a web page look great on the Android web browser
* Convert a website into a web application, complete with progress indicators and more
* Add animation with jQTouch to make your web app look and feel like a native Android app
* Take advantage of client-side data storage with apps that run even when the Android device is offline
* Use PhoneGap to hook into advanced Android features — including the accelerometer, geolocation, and alerts
* Test and debug your app on the Web under load with real users, and then submit the finished product to the Android Market

Instantiating Colors in Android

this posts's photo
A recent Android project for my Mobile Application Development class required us to draw 2d shapes and make a design. Android provides 12 Color constants for general use. The constructor for the Color object takes an int as a parameter. I wanted to draw some shapes in the appropriate “Android Green” (#a4c639), but the solution was not instantly obvious to me.

Method #1: Create an Instance of android.graphics.Color

the interesting, yet less flexible way…

From the Android reference:

The Color class defines methods for creating and converting color ints. Colors are represented as packed ints, made up of 4 bytes: alpha, red, green, blue. The values are unpremultiplied, meaning any transparency is stored solely in the alpha component, and not in the color components. The components are stored as follows (alpha << 24) | (red << 16) | (green << 8) | blue. Each component ranges between 0..255 with 0 meaning no contribution for that component, and 255 meaning 100% contribution. Thus opaque-black would be 0xFF000000 (100% opaque but no contributions from red, green, or blue), and opaque-white would be 0xFFFFFFFF

So what exactly does that techno-babble mean? I finally deciphered it…

Basically you start with the hex code for the color you want such as #a4c639. Prefix your integer with 0x, add 2 characters for transparenecy (00 for full transparency up to FF for full opacity), then add your 6 character hex color.

For example:

#a4c639 would become 0xFFA4C639.

Full post >>

© 2012 Tweak Blog Suffusion theme by Sayontan Sinha