Created
October 24, 2011 19:21
-
-
Save philayres/1309895 to your computer and use it in GitHub Desktop.
Unity indicator for simple clock and date display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Unity indicator for evolution-less clock and date display | |
# author: phil ayres | |
# 24 Oct 2011 | |
import gobject | |
import gtk | |
import appindicator | |
import os, sys | |
import time | |
from time import gmtime, strftime | |
if __name__ == "__main__": | |
#def on_left_click(widget,data=None): | |
# Placeholder for later | |
def on_timer(args=None): | |
ind.set_label(strftime("%H:%M",time.localtime())) | |
item.set_label(strftime("%a, %d %b %Y - %H:%M",time.localtime())) | |
return True | |
ind = appindicator.Indicator ("simple-clock-client", "clock", appindicator.CATEGORY_APPLICATION_STATUS) | |
ind.set_status (appindicator.STATUS_ACTIVE) | |
ind.set_label(strftime("%H:%M",time.localtime())); | |
menu = gtk.Menu() | |
item = gtk.MenuItem(strftime("%a, %d %b %Y",time.localtime())) | |
#item.connect("activate", on_left_click) | |
item.show() | |
menu.append(item) | |
ind.set_menu(menu) | |
gtk.timeout_add(1000, on_timer) | |
gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Step by step details for installing the indicator:
Download the Gist using the download button above.
Extract the file from the archive file then find the file using the file browser, right click and select Extract Here (or use the command line tar -zxvf gist1309895-43a546ee21b5c650b81ab41e04a887775c2cf16d.tar.gz if you prefer)
Go to your Home directory, and create a new directory called Scripts
Move the extracted file to this new directory.
Hit Ctrl-Alt-T to open a terminal (or through the Unity Dash type Terminal in the search box).
At the prompt, type the following and enter your password when prompted:
sudo apt-get install wmctrl
Follow any prompts to install the package.
Then, we need to make the indicator script executable. In the terminal, type:
chmod 755 ~/Scripts/display-indicator.py
Now, to add the date time indicator to run automatically at startup, search for "Startup Applications" in Dash, click "Add", under "Name" enter "Date Time" and under "Command" click "Browse" and select "desktop-indicator.py" from your Scripts directory.
You may log-off and log in to get the indicator to display, or just run the following from the terminal:
~/Scripts/display-indicator.py &
That's all. Please feel free to Star this gist so others can find it.