[Share Experiences] conky-manager桌面优化,股票信息,配置分享
Tofloor
poster avatar
datacl
deepin
2022-02-14 22:09
Author

使用conky 和conky-manager,进行桌面优化,方便大家上班滑水,话不多说,先上图。

image.png

使用步骤:

1.安装conky-manager

参考文档

2.股票行情拉取脚本

配置文件 /opt/conky/config.json

{
    "his":[
        "sz002911",
        "sz000807",
        "sz002422"
    ],
    "indexs":[
        "sh000001",
        "sz399001",
        "sz399006",
        "sh000688"
    ],
    "holds":{
        "sz300259": {"symbol": "sz300259","hold": 5300},
        "sz000717": {"symbol": "sz000717","hold": 10000},
        "sz002185": {"symbol": "sz002185","hold": 7900},
        "sh601336": {"symbol": "sh601336","hold": 600},
        "sh601933": {"symbol": "sh601933","hold": 3300},
        "sz300476": {"symbol": "sz300476","hold": 100},
        "sz002245": {"symbol": "sz002245","hold": 8100},
        "sh600206": {"symbol": "sh600206","hold": 6100},
        "sz301227": {"symbol": "sz301227","hold": 500},
        "sh600031": {"symbol": "sh600031","hold": 2400},
        "sh601877": {"symbol": "sh601877","hold": 100},
        "sh601995": {"symbol": "sh601995","hold": 1200}
    }
}

行情python脚本/opt/conky/stock_tencent.py

#!/usr/bin/python3
import requests
import json
import time

output_curr = ''

URL = 'http://qt.gtimg.cn/r=0.8409869808238q='
CONFIG_NAME = '/opt/conky/config.json'
config = {}
sum_profit = 0

def getCurrPrint(name, code, price, diff, percent, exchange_rate, profit):
    output = ''
    if percent > 0:
        color = '#ff0000'
    elif percent < 0:
        color = '#088e1f'
    else:
        color = ''
    output += '  ${color %s}%s%s${alignr}%s%s%s%s\n'  # color, code, name, price percent
    return output % (color, '{: <10}'.format(code), '{: <6}'.format(name), format(price, '.2f'), '{: >8}'.format(format(percent, '.2f') + '%'),'{: >8}'.format(format(exchange_rate, '.2f') + '%'), '{: >6}'.format(profit))


def parseResp(resp):
    global output_curr
    global sum_profit
    inresp = resp.replace('\n','').split(';')
    fields = ['证券代码','未知','名字','代码','当前价格','昨收','今开','成交量(手)','外盘','内盘','买一','买一量(手)','买二','买二量(手)','买三','买三量(手)','买四','买四量(手)','买五','买五量(手)','卖一','卖一量','卖二','卖二量','卖三','卖三量','卖四','卖四量','卖五','卖五量','最近逐笔成交','时间','涨跌','涨跌%','最高','最低','价格/成交量(手)/成交额','成交量(手)','成交额(万)','换手率','市盈率','未知2','最高','最低','振幅','流通市值','总市值','市净率','涨停价','跌停价']
    rst = []
    it = iter(inresp)    # 创建迭代器对象
    for x in it:
        inx = x.replace('v_','"').replace('="','~')
        inx = inx[inx.find('"') + 1: inx.rfind('"')].split('~')
        rst.append(dict(zip(fields,inx)))
    output_curr += '  ${color %s}%s%s${alignr}%s%s%s%s\n' % ('', '{: <8}'.format('代码'), '{: <8}'.format('名称'), '现价','{: >8}'.format('涨幅%'), '{: >6}'.format('换手%'), '{: >4}'.format('盈亏'))

    for symbol in rst:
        name = symbol.get('名字')
        code = symbol.get('证券代码')
        if code == '':
            continue
        price = float(symbol.get('当前价格'))
        diff = float(symbol.get('涨跌'))
        profit = 0
        if code in config["holds"]:
            profit = round(diff*config["holds"][code]["hold"])
        sum_profit += profit
        percent = round(float(symbol.get('涨跌%')),2)
        exchange_rate = float(symbol.get('换手率'))
        output_curr += getCurrPrint(name, code, price, diff, percent, exchange_rate, profit)
  
def loadConfig():
    global config
    config = json.load(open(CONFIG_NAME))
    symbols = map(lambda x: x, config["holds"].keys())
    return symbols


def main():
    global config
    global output_curr
    global URL
    global sum_profit
    if time.strftime("%H", time.localtime()) <= '08' or time.strftime("%H", time.localtime()) >= '16' or time.strftime("%w", time.localtime()) == '6' or time.strftime("%w", time.localtime()) == '0':
        # 周末、早上9点之前、下午4点以后不更新
        output_curr += '${color #ff0000}股票:/opt/conky/config.json${hr 2}${font LCD:pixelsize=14:bold}\n${color }    周末、早上9点之前、下午4点以后不更新。'
        print(output_curr)
        return
    SYMBOLS = loadConfig()
    indexs = map(lambda x: x, config["indexs"])
    URL = URL + ','.join(indexs) + ',' + ','.join(SYMBOLS)
    resp = requests.get(URL,timeout=5).text
    parseResp(resp)
    if sum_profit > 0:
        color = '#ff0000'
    elif sum_profit < 0:
        color = '#088e1f'
    else:
        color = ''
    output_stock = '${color #0066ff}股票:/opt/conky/config.json${alignr}${color %s}合计:%s${font LCD:pixelsize=14:bold}\n' % (color,sum_profit)
    print(output_stock + output_curr)


if __name__ == '__main__':
	main()

3.conky配置文件~/.conky/User Conky/conky01

conky.config = {
        background = true,
        update_interval = 5,
    draw_shades = true,

        cpu_avg_samples = 1,
        net_avg_samples = 2,
        temperature_unit = 'celsius',

        double_buffer = true,
        no_buffers = true,
        text_buffer_size = 2048,

        gap_x = 940,
        gap_y = 10,
        minimum_width = 400, 
    minimum_height = 330,
        maximum_width = 600,

    own_window = true,
    own_window_transparent = false,
    own_window_argb_visual = true,
    own_window_argb_value = 90,
    own_window_type = 'normal',
    own_window_colour = '#000000',
    own_window_class = 'conky-semi',
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',

        border_inner_margin = 0,
        border_outer_margin = 5,
        alignment = 'tl',


        draw_shades = true,
        draw_outline = false,
        draw_borders = false,
        draw_graph_borders = false,

        override_utf8_locale = true,
        use_xft = true,
        font = 'caviar dreams:size=10',
        xftalpha = 0,
        uppercase = false,

-- Defining colors
        default_color = '#FFFFFF',
-- Shades of Gray
        color1 = '#DDDDDD',
        color2 = '#AAAAAA',
        color3 = '#888888',
-- Orange
        color4 = '#EF5A29',
-- Green
        color5 = '#77B753',
-- Red
        color6 = '#D61D1D', 

--# System information using conky capabilities
-- 
-- ${font LCD:pixelsize=16:bold}
-- ${color #088e1f}内核:${color}$alignr$kernel
-- ${color #088e1f}已开机:${color}$alignr$uptime

};

conky.text = [[
${font LCD:pixelsize=46:bold}${alignr}${time %H:%M}
${font LCD:pixelsize=20:bold}${alignr}${color #0066ff}${time %Y年%b%d日}${color}
${font LCD:pixelsize=20:bold}${alignr}${color #0066ff}${time 星期%a}${color}
${font LCD:pixelsize=14}
${execpi 3 /usr/bin/python3 /opt/conky/weather.py}
${font LCD:pixelsize=16:bold}
${color #0066ff}CPU温度:${color}${hr 2}
  CPU1 温度: $alignr${exec sensors | grep 'Core 0' | cut -c17-25}
  CPU2 温度: $alignr${exec sensors | grep 'Core 1' | cut -c17-25}
 
${color #0066ff}CPU占用:${color}$cpu%  $cpubar
  ${top name 1} ${alignr}${top cpu 1}% 
  ${top name 2} ${alignr}${top cpu 2}% 
  ${top name 3} ${alignr}${top cpu 3}% 
  ${top name 4} ${alignr}${top cpu 4}% 

${execpi 3 /usr/bin/python3 /opt/conky/stock_tencent.py}
]];

时间表盘:$HOME/.conky/rev_midi/cups_n_saucers.lua

---
--==============================================================================
--                              Cups and Saucers
--                               Lua conky script
--
--  author  : Abu Yahya
--  license : Distributed under the terms of GNU GPL v3
--  05.06.2012
-- v.2.0.1
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
----Adjustable Settings 
coffee_table= {
    {
    name='time2',                  arg='%I.%M',                    max_value=12,
    x=50+12+2,                     y=50+12+2,
    cup_radius=10,
    cup_wall_thickness=90,
    total_angle=360,          
    cup_bg_clr=0xffffff,           cup_bg_alpha=0.0,
    cup_fg_clr=0xFFFFFF,           cup_fg_alpha=0.0,
    handle_length=10*2,              handle_circ=6,
    handle_fg_clr=0xFFFFFF,        handle_fg_alpha=1.0,
    graduation_radius=50,
    graduation_thickness=7,        graduation_mark_circ=2,
    graduation_mark_angle=30,
    graduation_fg_clr=0xFFFFFF,    graduation_fg_alpha=0.5,
    saucer_thickness=2,            thick_saucer_circ=1,  
    saucer_radius=50+12,           thin_saucer_circ=23/24,  
    saucer_fg_clr=0xFFFFFF,        saucer_fg_alpha=0.8, 
    saucer_mark_fg_clr=0xFFFFFF,   saucer_mark_fg_alpha=1,
    inner_saucer=true, 
    txt_weight=0,                  txt_size=7.0,
    txt_fg_clr=0xFFFFFF,           txt_fg_alpha=0.0,
    caption='',                    caption2='',
    },
    {
    name='time',                   arg='%M',                    max_value=60,
    x=50+12+2,                     y=50+12+2,
    cup_radius=16,                 cup_wall_thickness=120,
                                   total_angle=360,       
    cup_bg_clr=0xffffff,           cup_bg_alpha=0.0,
    cup_fg_clr=0xFFFFFF,           cup_fg_alpha=0.0,
    graduation_radius=50,
    graduation_thickness=7,        graduation_mark_circ=2,
    graduation_mark_angle=90,
    graduation_fg_clr=0xFFFFFF,    graduation_fg_alpha=0.5,
    handle_length=16*2,              handle_circ=4,
    handle_fg_clr=0xFFFFFF,        handle_fg_alpha=1.0,
    saucer_thickness=2,            thick_saucer_circ=1,
    saucer_radius=50+8,            thin_saucer_circ=23/24,  
    saucer_fg_clr=0xFFFFFF,        saucer_fg_alpha=0.8,
    saucer_mark_fg_clr=0xFFFFFF,   saucer_mark_fg_alpha=1,
    txt_weight=0,                  txt_size=7.0,
    txt_fg_clr=0xFFFFFF,           txt_fg_alpha=0.0,
    caption='',                    caption2='',
    },
    {
    name='time',                   arg='%S',                    max_value=60,
    x=50+12+2,                     y=50+12+2,
    cup_radius=22,                 cup_wall_thickness=120,
                                   total_angle=360,     
    cup_bg_clr=0xffffff,           cup_bg_alpha=0.0,
    cup_fg_clr=0xFFFFFF,           cup_fg_alpha=0.0,
    handle_fg_clr=0xFFFFFF,        handle_fg_alpha=1.0,
    handle_length=22*2,         handle_circ=2,
    graduation_radius=50,
    graduation_thickness=3,        graduation_mark_circ=1,
    graduation_mark_angle=6,
    graduation_fg_clr=0xFFFFFF,    graduation_fg_alpha=0.8,
    saucer_thickness=2,                thick_saucer_circ=1,
    saucer_radius=50+4,            thin_saucer_circ=23/24,  
    saucer_fg_clr=0xFFFFFF,        saucer_fg_alpha=0.8,
    saucer_mark_fg_clr=0xFFFFFF,   saucer_mark_fg_alpha=1,
    txt_weight=0,                  txt_size=7.0,
    txt_fg_clr=0xFFFFFF,           txt_fg_alpha=0.0,
    caption='',                    caption2='',
    }
}
  
--Fixed code -do not edit unless you know what you are doing------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- converts color in hexa to decimal
function rgb_to_r_g_b(clr, alpha)
    return ((clr / 0x10000) % 0x100) / 255., ((clr / 0x100) % 0x100) / 255., (clr % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
------------------------------------------------------------------------
-- displays cups and saucers
local function draw_coffee_table(display, data, value) 
     max_value = data['max_value']
     x, y = data['x'], data['y']
     if x==nil then x=conky_window.width/2 end
     if y==nil then y=conky_window.height/2 end
     cup_radius = data['cup_radius']  
     if cup_radius==nil then cup_radius=conky_window.width/4 end
     cup_wall_thickness = data['cup_wall_thickness']
     if cup_wall_thickness==nil then cup_wall_thickness=20 end
     handle_length, handle_circ = data['handle_length'], data['handle_circ']
     if handle_length==nil then handle_length=20 end
     if handle_circ==nil then handle_circ=1 end
     cup_start_angle = data['cup_start_angle']
     if cup_start_angle == nil then cup_start_angle =0 end
     total_angle = data['total_angle']
     if total_angle == nil then total_angle=360 end
     cup_sector_angle = (math.abs(total_angle))/max_value  
     cup_end_angle = total_angle + cup_start_angle
     cup_bg_clr, cup_bg_alpha = data['cup_bg_clr'], data['cup_bg_alpha']
     if cup_bg_clr==nil then cup_bg_clr =0xffffff end
     cup_fg_clr, cup_fg_alpha = data['cup_fg_clr'], data['cup_fg_alpha']
     if cup_fg_clr==nil then cup_fg_clr =0xffffff end
     if cup_fg_alpha==nil then cup_fg_alpha=0 end
     handle_fg_clr, handle_fg_alpha = data['handle_fg_clr'], data['handle_fg_alpha']  
     if handle_fg_clr==nil then handle_fg_clr = 0xffffff end
     if handle_fg_alpha==nil then handle_fg_alpha=0 end
   
     saucer_radius = data['saucer_radius']
     if saucer_radius==nil then saucer_radius=conky_window.width/2 end 
     total_saucer_angle=data['total_saucer_angle']
     if total_saucer_angle==nil then total_saucer_angle=360 end 
     saucer_sector_angle=(math.abs(total_saucer_angle))/max_value  
     saucer_thickness = data['saucer_thickness']
     if saucer_thickness==nil then saucer_thickness=6 end
     saucer_fg_clr = data['saucer_fg_clr']
     if saucer_fg_clr ==nil then saucer_fg_clr=0 end
     saucer_fg_alpha = data['saucer_fg_alpha']
     if saucer_fg_alpha ==nil then saucer_fg_alpha=0 end
   
     saucer_mark_fg_alpha = data['saucer_mark_fg_alpha']
     if saucer_mark_fg_alpha ==nil then saucer_mark_fg_alpha=0 end
     saucer_mark_fg_clr = data['saucer_mark_fg_clr']
     if saucer_mark_fg_clr ==nil then saucer_mark_fg_clr=0xffffff end
     thick_saucer_circ = data['thick_saucer_circ']
     if thick_saucer_circ==nil then thick_saucer_circ =0.9 end
     thin_saucer_circ = data['thin_saucer_circ']
     if thin_saucer_circ==nil then thin_saucer_circ =0.9 end
     inner_saucer = data['inner_saucer']
   
     graduation_radius = data['graduation_radius']
     if graduation_radius ==nil then graduation_radius = conky_window.width/3 end
     graduation_thickness, graduation_mark_circ = data['graduation_thickness'], data['graduation_mark_circ']
     if graduation_thickness ==nil then graduation_thickness = 2 end
     if graduation_mark_circ ==nil then graduation_mark_circ = 1 end
     graduation_mark_angle = data['graduation_mark_angle']
     if graduation_mark_angle == nil then graduation_mark_angle = total_angle/10 end
     graduation_fg_clr, graduation_fg_alpha = data['graduation_fg_clr'], data['graduation_fg_alpha']
     if graduation_fg_clr ==nil then graduation_fg_clr= 0xffffff end
     if graduation_fg_alpha==nil then graduation_fg_alpha =0 end
   
   
     txt_weight, txt_size = data['txt_weight'], data['txt_size']
     if txt_weight == nil then txt_weight=1 end
     if txt_size == nil then txt_size=8 end
     txt_fg_clr, txt_fg_alpha = data['txt_fg_clr'], data['txt_fg_alpha']
     if txt_fg_clr ==nil then txt_fg_clr= 0xffffff end
     if txt_fg_alpha==nil then txt_fg_alpha =0 end
     caption = data['caption']
     if caption==nil then caption='' end
     caption2 = data['caption2']
     if caption2==nil then caption2='' end
     xtxt, ytxt= data ['xtxt'], data['ytxt']
     if xtxt ==nil then xtxt=0 end
     if ytxt ==nil then ytxt=0 end

--convert degree to rad and rotate (0 degree is top/north)
    function angle_to_position(start_angle, current_angle)  
      if total_angle < 0 then 
        local pos = start_angle - current_angle
        return ( ( pos * (math.pi / 180) ) - (math.pi / 2) )
      else 
        local pos = current_angle + start_angle 
        return ( ( pos * (math.pi / 180) ) - (math.pi / 2) ) 
      end   
    end
--cup centre background  
  if cup_bg_alpha >0   then
    if total_angle < 0 then
      cairo_arc_negative(display, x, y, cup_radius, angle_to_position(cup_start_angle, 0), angle_to_position(cup_end_angle, 0))
    else
      cairo_arc(display, x, y, cup_radius, angle_to_position(cup_start_angle, 0), angle_to_position(cup_start_angle, cup_end_angle))
    end
    cairo_set_source_rgba(display, rgb_to_r_g_b(cup_bg_clr, cup_bg_alpha))
    cairo_set_line_width(display, cup_wall_thickness)
    cairo_stroke(display)
  end 
--cup wall fg  
  if cup_fg_alpha > 0 then 
   local fg_stop_arc = (cup_sector_angle * value)
    if total_angle < 0 then
        cairo_arc_negative(display, x, y, cup_radius, angle_to_position(cup_start_angle, 0), angle_to_position(cup_start_angle, fg_stop_arc))
    else
        cairo_arc(display, x, y, cup_radius, angle_to_position(cup_start_angle, 0), angle_to_position(cup_start_angle, fg_stop_arc))
    end
    cairo_set_source_rgba(display, rgb_to_r_g_b(cup_fg_clr, cup_fg_alpha))
    cairo_set_line_width(display, cup_wall_thickness)
    cairo_stroke(display)
  end
-- cup handle
  if handle_fg_alpha>0 then 
    local start_handle = (cup_sector_angle * value) - (handle_circ*0.5)
    local stop_handle = (cup_sector_angle * value) +  (handle_circ*0.5)
    if total_angle < 0 then
        cairo_arc_negative(display, x, y, cup_radius, angle_to_position(cup_start_angle, start_handle), angle_to_position(cup_start_angle, stop_handle))
    else
        cairo_arc(display, x, y, cup_radius, angle_to_position(cup_start_angle, start_handle), angle_to_position(cup_start_angle, stop_handle))
    end
    cairo_set_line_width(display, handle_length)  
    cairo_set_source_rgba(display, rgb_to_r_g_b(handle_fg_clr, handle_fg_alpha))
    cairo_stroke(display)
  end
--saucers   
---thick saucer   
    if saucer_fg_alpha > 0 and (thin_saucer_circ >0 or thick_saucer_circ > 0)
      then 
        if value < (max_value/2) 
        then j = value + ((max_value*total_saucer_angle)/720)
        else j = value - ((max_value*total_saucer_angle)/720)
        end

    local start_saucer = (saucer_sector_angle * value) - (value*saucer_sector_angle*1*thick_saucer_circ)  --计算指针圈层跟随指针圈层变厚
    local stop_saucer = (saucer_sector_angle * value) + (value*saucer_sector_angle*0*thick_saucer_circ)
    if total_angle < 0 then
        cairo_arc_negative(display, x, y, saucer_radius, angle_to_position(cup_start_angle, start_saucer), angle_to_position(cup_start_angle, stop_saucer))
    else
        cairo_arc(display, x, y, saucer_radius, angle_to_position(cup_start_angle, start_saucer), angle_to_position(cup_start_angle, stop_saucer))
    end
    cairo_set_source_rgba(display, rgb_to_r_g_b(saucer_fg_clr, saucer_fg_alpha))
    cairo_set_line_width(display, saucer_thickness)
    cairo_stroke(display)
    --thin saucer
      if inner_saucer == true 
      then rt = (saucer_radius - 0.5) + (0.5 * saucer_thickness)
      else rt = (saucer_radius + 0.5) - (0.5 * saucer_thickness)  
      end
    local start_thin_saucer = (saucer_sector_angle * j) - (max_value *0.5*saucer_sector_angle*thin_saucer_circ)
    local stop_thin_saucer = (saucer_sector_angle * j) + (max_value *0.5*saucer_sector_angle*thin_saucer_circ)
    if total_angle < 0 then
        cairo_arc_negative(display, x, y, rt, angle_to_position(cup_start_angle, start_thin_saucer), angle_to_position(cup_start_angle, stop_thin_saucer))
    else
        cairo_arc(display, x, y, rt, angle_to_position(cup_start_angle, start_thin_saucer), angle_to_position(cup_start_angle, stop_thin_saucer))
    end
    cairo_set_source_rgba(display, rgb_to_r_g_b(saucer_fg_clr, saucer_fg_alpha))
    cairo_set_line_width(display, 1)
    cairo_stroke(display)
   end
--saucer mark
    if saucer_mark_fg_alpha > 0 then 
        local start_cm = (saucer_sector_angle * value) - (handle_circ *0.5 )
        local stop_cm = (saucer_sector_angle * value) + (handle_circ *0.5 )
        if total_angle < 0 then
          cairo_arc_negative(display, x, y, saucer_radius, angle_to_position(cup_start_angle, start_cm), angle_to_position(cup_start_angle, stop_cm))
        else
          cairo_arc(display, x, y, saucer_radius, angle_to_position(cup_start_angle, start_cm), angle_to_position(cup_start_angle, stop_cm))
        end
        cairo_set_source_rgba(display, rgb_to_r_g_b(saucer_mark_fg_clr, saucer_mark_fg_alpha))
        cairo_set_line_width(display, saucer_thickness)
        cairo_stroke(display)
    end 
--graduation mark 
     if graduation_radius > 0 and graduation_thickness > 0 and graduation_mark_angle > 0 then
        number_graduation = (math.abs(total_angle) +1)/ graduation_mark_angle
        local start_arc_grad = 0
        local stop_arc_grad = 0
        local i = 0
        while i < number_graduation do        
            local start_arc_grad = (graduation_mark_angle * (i)) - (graduation_mark_circ *0.5)
            local stop_arc_grad = (graduation_mark_angle * (i)) + (graduation_mark_circ *0.5)
            if total_angle < 0 then
              cairo_arc_negative(display, x, y, graduation_radius, angle_to_position(cup_start_angle, start_arc_grad), angle_to_position(cup_start_angle, stop_arc_grad))
            else
              cairo_arc(display, x, y, graduation_radius, angle_to_position(cup_start_angle, start_arc_grad), angle_to_position(cup_start_angle, stop_arc_grad))
            end
            cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_clr,graduation_fg_alpha))
            cairo_set_line_width(display, graduation_thickness)
            cairo_stroke(display)        
            i = i + 1
        end
    end   
-- text
  if txt_fg_alpha>0 then 
    cairo_select_font_face (display, "hooge 05_53", CAIRO_FONT_SLANT_NORMAL, txt_weight);
    cairo_set_font_size (display,txt_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_clr, txt_fg_alpha))
    cairo_move_to (display,x+xtxt,y+ytxt)
    cairo_show_text (display, caption ) cairo_show_text (display,value)cairo_show_text (display, caption2 )
    cairo_stroke (display)
  end
end
-------------------------------------------------------------------------------
-- loads data and displays table_settings

function display_coffee_table(display)
    local function load_coffee_table(display, data)
        local str, value = '', 0   
        if data['name'] == 'time2' then
            local max_value = data['max_value']
            str = string.format('${time %s}', data['arg'])
            str = conky_parse(str)
            local value2 = tonumber(str:sub(0,2))
            if value2 == max_value then value2 = 0 end
            value = value2 + (tonumber(str:sub(4,5))/60)                
        else
            str = string.format('${%s %s}',data['name'], data['arg'])
            str = conky_parse(str)
            value = tonumber(str)
        end 
        if value == nil then value = 0 end
        draw_coffee_table(display, data, value)
    end
    for i in pairs(coffee_table) do
        load_coffee_table(display, coffee_table[i])
    end
end
-------------------------------------------------------------------------------
runscheck = 0 -- fix for draw shades running script twice on every update
function conky_main()
    if conky_window == nil then 
        return
    end
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local display = cairo_create(cs)
    local updates = conky_parse('${updates}')
    update_num = tonumber(updates)
    if update_num > 5 then
      cairo_set_antialias (display, CAIRO_ANTIALIAS_SUBPIXEL)
      display_coffee_table(display)
      cairo_set_antialias (display, CAIRO_ANTIALIAS_DEFAULT)
    end  
    cairo_surface_destroy(cs)
    cairo_destroy(display)
end

时间表盘 ~/.conky/rev_midi/conkyrc

conky.config = {
-- — Conky settings — #
        background = true,
        update_interval = 1,
        total_run_times = 0,
        net_avg_samples = 2,
        override_utf8_locale = true,
        double_buffer = true,
        no_buffers = true,


-- — Window specifications — #

        own_window_class = 'Conky',
        own_window = true,
        own_window_type = 'normal',
        own_window_transparent = true,
        own_window_argb_visual = true,
    own_window_argb_value = 0,
        own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',

        border_inner_margin = 0,
        border_outer_margin = 0,

        minimum_width = (50+12+2)*2, minimum_height = (50+12+2)*2,
        maximum_width = (50+12+2)*2,

        alignment = 'tl',

        gap_x = 940+50,
        gap_y = 10,

-- — Graphics settings — #
        draw_shades = false,
        draw_outline = false,
        draw_borders = false,
        draw_graph_borders = false,

-- — Text settings — #
        use_xft = true,
        font = 'LCDMono2:size=7',
        xftalpha = 1.0,

        default_color = '#FFFFFF',

        uppercase = false,
        use_spacer = 'right',


-- — Lua Load — #


        lua_load = '$HOME/.conky/rev_midi/cups_n_saucers.lua',
        lua_draw_hook_post = 'main',

};

conky.text = [[
]];

启动脚本 ~/.conky/conky-startup.sh

killall conky
sleep 30
conky -c "$HOME/.conky/User Conky/conky01" &
sleep 30
conky -c $HOME/yangjk/.conky/rev_midi/conkyrc &

Reply Favorite View the author
All Replies
andktan
deepin
2022-02-14 23:27
#1

agree

Reply View the author
h_b
deepin
2022-02-15 18:40
#2

image.png

Reply View the author