Quantcast

Add CPU and Mem widgets to config

Scott Sibley [08-19-10 - 12:19]
Add CPU and Mem widgets to config
Filename
config.lua
diff --git a/config.lua b/config.lua
index 7618363..9b56c2b 100644
--- a/config.lua
+++ b/config.lua
@@ -1,16 +1,17 @@
-StarTip.config = [[

-ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC, ALIGN_PINGPONG = 1, 2, 3, 4, 5, 6
-SCROLL_RIGHT, SCROLL_LEFT = 1, 2
+
+local ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC, ALIGN_PINGPONG = 1, 2, 3, 4, 5, 6
+local SCROLL_RIGHT, SCROLL_LEFT = 1, 2

 local foo = 500
-return {
+
+StarTip.config = {
     ["display_startip"] = {
 		["driver"] = "qtip",
 		["layers"] = 3,
 		["background"] = "d9ccf16f",
-		["rows"] = 2,
-		["cols"] = 20,
+		["rows"] = 6,
+		["cols"] = 40,
 		["layout-timeout"] = 0,
 		["update"] = 25,
 		["widget0"] = "widget_key_up",
@@ -40,6 +41,14 @@ return {
 			["col1"] = "widget_level_label",
 			["col9"] = "widget_level",
 		},
+		["row5"] = {
+			["col1"] = "widget_mem_label",
+			["col9"] = "widget_mem"
+		},
+		["row6"] = {
+			["col1"] = "widget_cpu_label",
+			["col9"] = "widget_cpu"
+		},
 		["transition"] = "U"
     },
 	["widget_name_label"] = {
@@ -95,6 +104,39 @@ return {
 		value = "return UnitLevel('player')",
 		cols = 10
 	},
+	["widget_mem_label"] = {
+		type = "text",
+		value = "return 'Memory:'",
+		cols = 9
+	},
+	["widget_mem"] = {
+		type = "text",
+		value = [[
+local mem, percent, memdiff, totalMem, totaldiff = GetMemUsage("StarTip")
+if mem then
+    self.memperc = memdiff / totaldiff * 100
+    return memshort(tonumber(format("%.2f", mem))) .. " (" .. format("%.2f", self.memperc) .. "%)"
+end]],
+		cols = 10,
+		update = 1000
+	},
+	["widget_cpu_label"] = {
+		type = "text",
+		value = "return 'CPU:'",
+		cols = 9
+	},
+	["widget_cpu"] = {
+		type = "text",
+		value = [[
+local cpu, percent, cpudiff, totalCPU, totaldiff = GetCPUUsage("StarTip")
+if cpu then
+    self.cpuperc = cpudiff / totaldiff * 100
+    return timeshort(cpu) .. " (" .. format("%.2f", self.cpuperc)  .. "%)"
+end
+]],
+		cols = 10,
+		update = 10000
+	},
 	["widget_icon_blob"] = {
 		["bitmap"] = {
     		["row1"] = ".....|.....|.....",
@@ -235,5 +277,4 @@ return {
 		["expression"] = "'%'",
 		["type"] = "text"
     }
-}
-]]
\ No newline at end of file
+}
\ No newline at end of file