Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2010
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. do
  2.     local cool = "88CC00"
  3.     local medi = "DDDD00"
  4.     local hot = "EE5555"
  5.     function conky_colorise_cpu(arg)
  6.         -- arg is which cpu
  7.         local color = "000000"
  8.         local perc = tonumber(conky_parse(string.format('${cpu cpu%i}',tonumber(arg))))
  9.         if perc == nil then
  10.             perc = -1
  11.         end
  12.         if perc <= 25 then
  13.             color = cool
  14.         elseif perc > 25 and perc < 80 then
  15.             color = medi
  16.         else
  17.             color = hot
  18.         end
  19.         return string.format('${color %s}%3i%%${color}',color,tonumber(perc))
  20.        
  21.     end
  22.  
  23.     function conky_format_speeds(arg)
  24.         downvalue = tonumber(conky_parse(string.format('${downspeedf %s}',arg)))
  25.         upvalue   = tonumber(conky_parse(string.format('${upspeedf %s}',arg)))
  26.         return string.format('${color %s}%5.0fkB/s${color} ${color %s}%5.0fkB/s${color}',cool,downvalue,hot,upvalue)
  27.     end
  28.  
  29.     function conky_colorise_mem(arg)
  30.         local color = "000000"
  31.         local perc = tonumber(conky_parse(string.format('${memperc}')))
  32.         if perc == nil then
  33.             perc = -1
  34.         end
  35.         if perc <= 25 then
  36.             color = cool
  37.         elseif perc > 25 and perc < 80 then
  38.             color = medi
  39.         else
  40.             color = hot
  41.         end
  42.         return string.format('${color %s}%s${color}/%s (${color %s}%3i%%${color})',
  43.             color,'${mem}','${memmax}',color,tonumber(perc)
  44.         )
  45.        
  46.     end
  47.  
  48.     function conky_weight_frequency(arg)
  49.         local freqs = {}
  50.         local max = 0
  51.         for i=1,tonumber(arg) do
  52.             freqs[i] = tonumber(conky_parse(string.format('${freq_g %s}',arg)))
  53.             if freqs[i] > max then
  54.                 max = freqs[i]
  55.             end
  56.         end
  57.         return string.format('%3.1f GHz',max)
  58.     end
  59.  
  60.     function conky_colorise_temps(what_, min__, max__)
  61.         local color = "000000"
  62.         local min_ = tonumber(min__)
  63.         local max_ = tonumber(max__)
  64.         what_ = string.format('${%s}',string.gsub(what_,"+"," "))
  65.         local what = tonumber(conky_parse(string.format('%s',what_)))
  66.         if tonumber(what) <= (min_ + 0.25*(max_-min_)) then
  67.             color = cool
  68.         elseif tonumber(what) > (min_ + 0.25*(max_-min_)) and
  69.                 tonumber(what) < (min_ + 0.80*(max_-min_)) then
  70.             color = medi
  71.         else
  72.             color = hot
  73.         end
  74.         return string.format('${color %s}%s°C${color}',color,what)
  75.     end
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement