All pastes #1705259 Raw Edit

Unnamed

public python v1 · immutable
#1705259 ·published 2009-12-07 07:45 UTC
rendered paste body
#!/usr/bin/env pythonfrom subprocess import Popen, PIPE# Define colorsclear = "\x1b[0m"# color = "\x1b[1;30m" # black# color2 = "\x1b[0;30m" # black# color = "\x1b[1;31m" # red # color2 = "\x1b[0;30m" # red# color = "\x1b[1;32m" # green# color2 = "\x1b[0;32m" # green# color = "\x1b[1;33m" # yellow# color2 = "\x1b[0;33m" # yellowcolor = "\x1b[1;34m" # bluecolor2 = "\x1b[0;34m" # blue# color = "\x1b[1;35m" # magenta# color2 = "\x1b[0;35m" # magenta# color = "\x1b[1;36m" # cyan# color2 = "\x1b[0;36m" # cyan# color = "\x1b[1;37m" # white# color2 = "\x1b[0;37m" # white# Define arrays containing values.list = []blank = ['']*10# Find running processesp1 = Popen(['ps', '-A'], stdout=PIPE)p2 = Popen(["awk", '{print $4}'], stdin=p1.stdout, stdout=PIPE)processes = p2.communicate()[0].split("\n")# Print coloured key with normal value.def output(key, value):	output = "%s%s:%s %s" % (color, key, clear, value)	list.append(output)# Define OSdef os_display(): 	os = "Arch Linux"		output('OS', os)# Define Kerneldef kernel_display():	kernel = Popen(['uname', '-r'], stdout=PIPE).communicate()[0].rstrip("\n")	output ('Kernel', kernel)# Define Uptimedef uptime_display():	p1 = Popen(['uptime'], stdout=PIPE)	p2 = Popen(['sed', '-e', 's/^.*up //', "-e", 's/, *[0-9]*.users.*//'], stdin=p1.stdout, stdout=PIPE)	uptime = p2.communicate()[0].rstrip("\n")	output ('Uptime', uptime)	p1 = p2 = None# Define Battery [Requires: acpi]def battery_display(): 	p1 = Popen(['acpi'], stdout=PIPE)	p2 = Popen(['sed', 's/.*, //'], stdin=p1.stdout, stdout=PIPE)	battery = p2.communicate()[0].rstrip("\n")	output ('Battery', battery)# Define Desktop Environmentdef de_display():	dict = {'gnome-session': 'GNOME',		'ksmserver': 'KDE',		'xfce-mcs-manager': 'Xfce'}	de = 'None found'	for key in dict.keys():		if key in processes: de = dict[key]	output ('DE', de)# Define Window Managerdef wm_display():        dict = {'awesome': 'Awesome',		'beryl': 'Beryl',		'blackbox': 'Blackbox',		'dwm': 'DWM',		'enlightenment': 'Enlightenment',                'fluxbox': 'Fluxbox',		'fvwm': 'FVWM',		'icewm': 'icewm',		'kwin': 'kwin',		'metacity': 'Metacity',                'openbox': 'Openbox',		'wmaker': 'Window Maker',		'xfwm4': 'Xfwm',		'xmonad': 'Xmonad'}          wm = 'None found'        for key in dict.keys():		if key in processes: wm = dict[key]        output ('WM', wm)# Define Packages (Number of Packages Installed on System)def packages_display():	p1 = Popen(['pacman', '-Q'], stdout=PIPE)	p2 = Popen(['wc', '-l'], stdin=p1.stdout, stdout=PIPE)	packages = p2.communicate()[0].rstrip("\n")	output ('Packages', packages)# Define File System Informationdef fs_display():	# Display root filesystem information. [Enabled by default]	p1 = Popen(['df', '-Th'], stdout=PIPE)	p2 = Popen(['grep', "/$"], stdin=p1.stdout, stdout=PIPE)	p3 = Popen(['awk', '{print $4}'], stdin=p2.stdout, stdout=PIPE)	root = p3.communicate()[0].rstrip("\n")	output ('Root', root)	# Display home filesystem information.	# Uncomment if you have a seperate home filesystem. [Disabled by default]	h1 = Popen(['df', '-Th'], stdout=PIPE)	h2 = Popen(['grep', "/home$"], stdin=h1.stdout, stdout=PIPE)	h3 = Popen(['awk', '{print $4}'], stdin=h2.stdout, stdout=PIPE)	home = h3.communicate()[0].rstrip("\n")	output ('Home', home)# Values to display.# Possible options: os, kernel, uptime, battery, de, wm, packages, fs.display = [ 'os', 'kernel', 'battery', 'uptime', 'de', 'wm', 'packages', 'fs' ]# Run functions found in 'display' array.for x in display:	funcname=x+"_display"	func=locals()[funcname]	func()# Fill 'list' array with with blank keys. [Do not remove, or it will break script]list.extend(blank)# Resultprint """%s%s               +                %s               #                %s              ###               %s%s             #####              %s%s             ######             %s%s            ; #####;            %s%s           +##.#####            %s%s          +##########           %s%s         ######%s#####%s##;         %s%s        ###%s############%s+        %s%s       #%s######   #######        %s%s     .######;     ;###;`\".      %s%s    .#######;     ;#####.       %s%s    #########.   .########`     %s%s   ######'           '######    %s%s  ;####                 ####;   %s  ##'                     '##   %s #'                         `#  %s                          """ % (color, color, color, color, list[0], color, list[1], color, list[2], color, list[3], color, list[4], color, list[5], color, color2, color, list[6], color, color2, color, list[7], color, color2, list[8], color2, list[9], color2, list[10], color2, list[10], color2, list[10], color2, color2, color2, clear)