Botspot / pi-apps

Raspberry Pi App Store for Open Source Projects
GNU General Public License v3.0
2.02k stars 205 forks source link

Conky Grapes #687

Closed ryanfortner closed 3 years ago

ryanfortner commented 3 years ago

conky-grapes.zip

A more modern conky theme that looks a lot better IMO. The install script will automatically check for existing .conkyrc configurations, and will ask you to uninstall the original Conky app before continuing.

68747470733a2f2f692e696d6775722e636f6d2f674c64556e42662e706e67

ryanfortner commented 3 years ago

if you want me to PR instead, if that would be easier @Botspot since you are busy, I can do that also

Botspot commented 3 years ago

if you want me to PR instead, if that would be easier @Botspot since you are busy, I can do that also

Rule of thumb:

I can try to test this right now, but keep in mind I'm leaving for a summer camp tomorrow and have to work around packing.

Botspot commented 3 years ago

Comments on your script

Comments on this line: cd ~/ && tar -xvf fonts.tar.gz && mv *.ttf ~/.local/share/fonts || error "Failed to extract the required fonts!" First, we don't need to cd into $HOME, because we're already there. Second, I don't like the idea of moving all ttf files from the home folder to ~/.local/share/fonts: what if the user already had some fonts there beforehand? (It sure would be annoying if all my fonts were "deleted" by a pi-app)

Comments on this line: rm .uuid || error "Failed to remove .uuid!" Uhh, what is this file, and are you 100% sure it's safe to remove it from the home directory?

And there's no need for this line: echo -n '' > ~/.config/autostart/conky.desktop

Comments on this line: conky -q -d -p 3 & While conky will run in the background, once the installation terminal closes, this process will be killed with it. Under normal circumstances for an normal command, we'd have to change this to setsid conky -q -d -p 3, but in this case, conky does this for us already by forking its own process to a background process.

ryanfortner commented 3 years ago

Thanks for your comments!

Comments on this line: cd ~/ && tar -xvf fonts.tar.gz && mv *.ttf ~/.local/share/fonts || error "Failed to extract the required fonts!" First, we don't need to cd into $HOME, because we're already there. Second, I don't like the idea of moving all ttf files from the home folder to ~/.local/share/fonts: what if the user already had some fonts there beforehand? (It sure would be annoying if all my fonts were "deleted" by a pi-app)

It won't remove any fonts in ~/.local/share/fonts/, it will only add some...

I'll take out the cd ~/ part.

Comments on this line: rm .uuid || error "Failed to remove .uuid!" Uhh, what is this file, and are you 100% sure it's safe to remove it from the home directory?

It's part of the fonts.tar.gz archive and is not necessary for the installation, so yes, it's safe to remove.

And there's no need for this line: echo -n '' > ~/.config/autostart/conky.desktop

I'll take this out, thanks for catching it :)

Comments on this line: conky -q -d -p 3 & While conky will run in the background, once the installation terminal closes, this process will be killed with it. Under normal circumstances for an normal command, we'd have to change this to setsid conky -q -d -p 3, but in this case, conky does this for us already by forking its own process to a background process.

i'll change it.

Botspot commented 3 years ago

Thanks for your comments!

No problem.

Comments on this line: cd ~/ && tar -xvf fonts.tar.gz && mv *.ttf ~/.local/share/fonts || error "Failed to extract the required fonts!" First, we don't need to cd into $HOME, because we're already there. Second, I don't like the idea of moving all ttf files from the home folder to ~/.local/share/fonts: what if the user already had some fonts there beforehand? (It sure would be annoying if all my fonts were "deleted" by a pi-app)

It won't remove any fonts in ~/.local/share/fonts/, it will only add some...

Consider this scenario: I (as a user) have downloaded some of my own font files to the home folder. Later I install Conky Grapes, and now all those fonts I downloaded are gone! :O I don't know where they went, and I will likely assume they were deleted. That is the problem with mv *.ttf ~/.local/share/fonts.

Botspot commented 3 years ago

Test results on my system:

ryanfortner commented 3 years ago
  • Conky failed to display properly. Based on the below screenshot, do you know what may be going wrong?

Do you have the .conky_rings.lua in the right place? It should have a . at the beginning of the file name.

Botspot commented 3 years ago
  • Conky failed to display properly. Based on the below screenshot, do you know what may be going wrong?

Do you have the .conky_rings.lua in the right place? It should have a . at the beginning of the file name.

Strangely, after 20 seconds or so, the rings do appear. I didn't notice this the first time, but later came back and there they were. 2021-05-26-222904_1366x768_scrot

Now that this app works, it's technically ready to add. But in my opinion, the monotone grey looks a bit boring. @chunky-milk, Would you be interested in changing a few colors to add some contrast? If not, I can add it as-is. For reference, here's my conky config that I later turned into Pi-Apps' default "Conky" app: 2021-05-26-223243_1366x768_scrot While the layout is worse, in my opinion the colors look a lot nicer and with good contrast. (On my desktop background at least)

ryanfortner commented 3 years ago

Sure, I think colors are a good idea. I'm just not sure how to change the colors ...

Botspot commented 3 years ago

Adding colors took a while, but was fairly easy. 2021-06-28-103445_1366x768_scrot Here's the conkyrc:

conky.config = {
    background = true,
    update_interval = 1,

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

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

    gap_x = 10,
    gap_y = 675,
    minimum_width = 470,
    maximum_width = 470,
    minimum_height = 400,

    own_window = true,
    own_window_type = 'normal',
    own_window_transparent = true,
    own_window_argb_visual = true,
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',

    border_inner_margin = 0,
    border_outer_margin = 0,
    alignment = 'top_right',

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

    override_utf8_locale = true,
    use_xft = true,
    font = 'Pf Tempesta Five:bold:size=6',
    xftalpha = 0.9,
    uppercase = false,

    default_color = '#999999',
    default_shade_color = 'red',
    default_outline_color = 'green',

    color1 = 'darkgrey',
    color2 = '#1994D1',
    color3 = '#ff7200',
    color4 = '#FF4A5C',

    lua_load = '~/.conky_rings.lua',
    lua_draw_hook_post = 'main'
}

conky.text = [[
# CPU / UPTIME
${voffset 5}${goto 298}${#FFFFFF}${freq}${color1} MHz${goto 360}Uptime ${#FFFFFF}${uptime_short}
# TEMP
${#A0FFA0}${alignr 118}${acpitemp}\u00b0C
${#80FF80}${voffset 1}${goto 295}CPU 1${alignr 118}${cpu cpu0}%
${#60FF60}${voffset 3}${goto 295}CPU 2${alignr 118}${cpu cpu1}%
${#40FF40}${voffset 3}${goto 295}CPU 3${alignr 118}${cpu cpu2}%
${#20FF20}${voffset 3}${goto 295}CPU 4${alignr 118}${cpu cpu3}%
# TOP CPU
${#20FF20}${goto 230}${voffset 5}${top name 1}${alignr 96}${top cpu 1}%
${#00FF00}${goto 230}${top name 2}${alignr 84}${top cpu 2}%
${#00DD00}${goto 230}${top name 3}${alignr 80}${top cpu 3}%
${#00BB00}${goto 230}${top name 4}${alignr 81}${top cpu 4}%
${#008800}${goto 230}${top name 5}${alignr 88}${top cpu 5}%
# HDD
${#FF2020}${voffset 42}${alignr 230}${fs_used /home} / ${fs_size /home} root
${#FF2020}${voffset 2}${alignr 230}${fs_used /boot} / ${fs_size /boot} boot
# MEMORY
${voffset 60}${goto 322}${#999999}ram %
${#00C0FF}${voffset 1}${goto 312}${top_mem name 1}
${#007aFF}${goto 308}${top_mem name 2}
${#0050FF}${goto 309}${top_mem name 3}
${#002aFF}${goto 314}${top_mem name 4}
${#0000FF}${goto 330}${top_mem name 5}
${#10AAFF}${voffset 5}${goto 348}SWAP ${alignr}${#1060FF}${swap} / ${swapmax}
${#10AAFF}${voffset 4}${goto 348}RAM ${alignr}${#1060FF}${mem} / ${memmax}
# VERSION
${#999999}${voffset 10}${goto 320}${execi 86400 uname} ${execi 86400 uname -m} ${execi 86400 uname -r}
]]

Here's my conky_rings.lua

require 'cairo'

normal="0xff0000"
warn="0xff7200"
crit="0xFF4A5C"

settings_table = {
    {
        name='acpitemp',
        arg='',
        max=80,
        bg_colour=0x001A00,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=360, y=120,
        radius=97,
        thickness=6,
        start_angle=0,
        end_angle=240
    },
    {
        name='acpitemp',
        arg='',
        max=80,
        bg_colour=0x001A00,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=360, y=120,
        radius=97,
        thickness=4,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu0',
        max=100,
        bg_colour=0x003000,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=360, y=120,
        radius=86,
        thickness=16,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu0',
        max=100,
        bg_colour=0x003000,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=360, y=120,
        radius=86,
        thickness=10,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0x005900,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=360, y=120,
        radius=71,
        thickness=15,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0x005900,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=360, y=120,
        radius=71,
        thickness=11,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu2',
        max=100,
        bg_colour=0x008000,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=360, y=120,
        radius=57,
        thickness=13,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu2',
        max=100,
        bg_colour=0x008000,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=360, y=120,
        radius=57,
        thickness=10,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu3',
        max=100,
        bg_colour=0x01B300,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=360, y=120,
        radius=44,
        thickness=13,
        start_angle=0,
        end_angle=240
    },
    {
        name='cpu',
        arg='cpu3',
        max=100,
        bg_colour=0x01B300,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=360, y=120,
        radius=44,
        thickness=9,
        start_angle=0,
        end_angle=240
    },
    {
        name='fs_used_perc',
        arg='/home',
        max=100,
        bg_colour=0x660000,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=250, y=225,
        radius=34,
        thickness=14,
        start_angle=0,
        end_angle=240
    },
    {
        name='fs_used_perc',
        arg='/home',
        max=100,
        bg_colour=0x660000,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=250, y=225,
        radius=34,
        thickness=10,
        start_angle=0,
        end_angle=240
    },
    {
        name='fs_used_perc',
        arg='/boot/',
        max=100,
        bg_colour=0xb30000,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=250, y=225,
        radius=21,
        thickness=12,
        start_angle=0,
        end_angle=240
    },
    {
        name='fs_used_perc',
        arg='/boot/',
        max=100,
        bg_colour=0xb30000,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=250, y=225,
        radius=21,
        thickness=10,
        start_angle=0,
        end_angle=240
    },
    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0x000199,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=340, y=300,
        radius=60,
        thickness=19,
        start_angle=180,
        end_angle=420
    },
    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0x0000ff,
        bg_alpha=0,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=340, y=300,
        radius=60,
        thickness=14,
        start_angle=180,
        end_angle=420
    },
    {
        name='swapperc',
        arg='',
        max=100,
        bg_colour=0x1030ff,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0,
        x=340, y=300,
        radius=45,
        thickness=12,
        start_angle=180,
        end_angle=420
    },
    {
        name='swapperc',
        arg='',
        max=100,
        bg_colour=0x1030ff,
        bg_alpha=1,
        fg_colour=0xffffff,
        fg_alpha=0.4,
        x=340, y=300,
        radius=45,
        thickness=10,
        start_angle=180,
        end_angle=420
    }
}

function rgb_to_r_g_b(colour, alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function draw_ring(display, t, pt)
    local w,h=conky_window.width,conky_window.height

    local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
    local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']

    local angle_0=sa*(2*math.pi/360)-math.pi/2
    local angle_f=ea*(2*math.pi/360)-math.pi/2
    local t_arc=t*(angle_f-angle_0)

    -- Draw background ring

    cairo_arc(display,xc,yc,ring_r,angle_0,angle_f)
    cairo_set_source_rgba(display,rgb_to_r_g_b(bgc,bga))
    cairo_set_line_width(display,ring_w)
    cairo_stroke(display)

    -- Draw indicator ring

    cairo_arc(display,xc,yc,ring_r,angle_0,angle_0+t_arc)
    cairo_set_source_rgba(display,rgb_to_r_g_b(fgc,fga))
    cairo_stroke(display)       
end

function conky_ring_stats(display)
    local function setup_rings(display,pt)
        local str=''
        local value=0

        str=string.format('${%s %s}',pt['name'],pt['arg'])
        str=conky_parse(str)

        value=tonumber(str)
        if value == nil then value = 0 end
        pct=value/pt['max']

        draw_ring(display, pct, pt)
    end

    for i in pairs(settings_table) do
        setup_rings(display, settings_table[i])
    end
end

function temp_watch()
    warn_value=55
    crit_value=65

    temperature=tonumber(conky_parse("${acpitemp}"))
end

function disk_watch()
    warn_disk=93
    crit_disk=98

    disk=tonumber(conky_parse("${fs_used_perc /home}"))

    disk=tonumber(conky_parse("${fs_used_perc /boot/}"))

end

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)

    temp_watch()
    disk_watch()

    if update_num > 5 then
        conky_ring_stats(display)
    end

    cairo_surface_destroy(cs)
    cairo_destroy(display)
end
Botspot commented 3 years ago

This app added to pi-apps with commit 832f3a2c2e70e0b41321480a428943645d873887

ryanfortner commented 3 years ago

Adding colors took a while, but was fairly easy.

Impressive! It looks a lot better now 👍