AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-540879

L_R's questions

Martin Hope
L_R
Asked: 2024-02-09 18:34:38 +0800 CST

{up, down}gráficos de velocidade não mostrados usando `lua_parse lua_func`

  • 5

Aqui está o meu conkyrc:

conky.config = {
    use_xft = true, -- use xft?
    font = 'DejaVuSans:size=9', -- font name
    xftalpha = 1,
    uppercase = false, -- all text in uppercase?
    pad_percents = 0,
    text_buffer_size = 2048,
    override_utf8_locale = true, -- Force UTF8? note that UTF8 support required XFT
    use_spacer = 'none', -- Add spaces to keep things from moving about?  This only affects certain objects.

    update_interval = 1, -- Update interval in seconds
    double_buffer = true, -- Use double buffering (reduces flicker, may not work for everyone)
    total_run_times = 0, -- This is the number of times Conky will update before quitting. Set to zero to run forever.

    -- Create own window instead of using desktop (required in nautilus)
    own_window = true,
    own_window_class = 'Conky',
    own_window_transparent = true,
    own_window_argb_visual = true,
    own_window_argb_value = 255,
    own_window_type = 'desktop', -- transparency seems to work without this line
    own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',

    -- Minimum size of text area
    minimum_height = 50,
    minimum_width = 210,

    draw_shades = false, -- draw shades?
    draw_outline = false, -- draw outlines?
    draw_borders = false, -- draw borders around text?
    draw_graph_borders = false, -- draw borders around graphs
    stippled_borders = 0, -- stripled borders?

    imlib_cache_size = 0, -- Imlib2 image cache size, in bytes. Increase this value if you use $image lots. Set to 0 to disable the image cache.

    -- Gap between borders of screen and text. Same thing as passing -x at command line
    gap_x = 90,
    gap_y = 5,

    alignment = 'middle_right', -- alignment on {y_axis}_{x_axis}

    cpu_avg_samples = 2, -- number of cpu samples to average. set to 1 to disable averaging
    net_avg_samples = 2, -- number of net samples to average. set to 1 to disable averaging

    no_buffers = true, -- Subtract file system buffers from used memory?

    default_color = 'e0e0e0',
    default_shade_color = '000000',
    default_outline_color = '000000',

    temperature_unit = 'celsius',

    color1 = 'ff55ff', -- heading's color
    color2 = 'ffffff', -- normal text's color

    lua_load = '.conky/netdevs.lua',
};

conky.text = [[
...
${color1}NET: ${hr 2}${color2}${lua_parse conky_show_netdevs}
...
]]

Aqui está .config/netdevs.lua:

-- conky_show_netdevs : template for network
-- usage : ${lua_parse conky_show_netdevs}

prev_result = ""

function conky_show_netdevs()
    updates = tonumber(conky_parse("${updates}"))
    interval = 10
    timer = (updates % interval)

    if timer == 0 or prev_result == "" then
        local netdevs_handle = io.popen("ip -j link show up | jq -r '.[] | select(.operstate == \"UP\" and .ifname != \"lo\") | .ifname'")
        local result = ""

        for netdev in netdevs_handle:lines() do
            result = result .. "\nIP (${color1}" .. netdev .. "${color2}): ${alignr}${addr " .. netdev .. "}\n" ..
                     "${color2}Up: ${color2}${upspeed " .. netdev .. "}/s${color1}${alignr}${upspeedgraph " .. netdev .. " 10,170}\n" ..
                     "${color2}Down: ${color2}${downspeed " .. netdev .. "}/s${color1}${alignr}${downspeedgraph " .. netdev .. " 10,170}\n" ..
                     "${color2}Total Down: ${color2}${totaldown " .. netdev .. "}${alignr}Total Up: ${totalup " .. netdev .. "}\n"
        end

        netdevs_handle:close()

        if result ~= "" then
            prev_result = result
        else
            prev_result = "\n"
        end
    end

    return prev_result
end

Tudo funciona, exceto s upspeedgraphe downspeedgraphs, retornados na conky_show_netdevs()saída da função.

Aqui está uma imagem dos gráficos que posso ver (as pequenas linhas na última seção da imagem; nas linhas onde estão presentes os textos "UP" e "DOWN"):

janela conky


Pelo que pude imaginar, pensei que esse problema fosse causado porque o conteúdo da função lua era analisado toda vez que o conky era recarregado, o que poderia fazer com que o gráfico fosse recarregado. Então, tentei aumentar o intervalo de atualização do conky para 10 segundos. Mas ainda assim, sem sorte :( 👎.


Diga-me por que isso está acontecendo e como resolver esse problema?

Obrigado 😊!

conky
  • 1 respostas
  • 10 Views
Martin Hope
L_R
Asked: 2023-03-09 16:34:51 +0800 CST

GDB falha ao baixar debuginfo para math.h

  • 5

Eu tenho um programa de relógio simples que usa math.hfunções. Estou atualmente em Kubuntu 21.10, a versão GCC é (Ubuntu 12.2.0-3ubuntu1) 12.2.0, e a versão GDB é (Ubuntu 12.1-3ubuntu2) 12.1.

O código-fonte do programa (embora possa não ser necessário):

#include <stdio.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#include "conio.h"
#include <sys/ioctl.h>
#include <stdlib.h>

#define PI 3.14159265358979323846264338327950288419716939937510
#define RAD_90 1.570796 // precomputed value of 90 degrees in radians
#define RAD_30 0.523599 // precomputed value of 30 degrees in radians
#define RAD_6 0.104720 // precomputed value of 6 degree in radians
#define RAD_1 0.017453 // precomputed value of 1 degree in radians

#define X 0 // x co-ordinate in array
#define Y 1 // y co-ordinate in array

int COLUMNS, ROWS;

#define CLOCK_RADIUS (COLUMNS/2)-1

#define FPS 24
#define MOVE_TO_HOME() (printf("\033[H"))
#define CLEAR_TERMINAL_SCREEN() (printf("\033[2J"))
#define cls() (CLEAR_TERMINAL_SCREEN())

void die(const char *s) {
    cls();
    printf("clock: error: %s: ", s);
    fflush(stdout);
    perror(NULL);
    fflush(stderr);
    exit(1);
}

char **output/*[ROWS][COLUMNS*2]*/;
struct tm *t = NULL;

void get_window_size(int *rows, int *cols) {;
    struct winsize ws;

    if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
        if(write(STDOUT_FILENO, "\x1b[999C\x1b[999B", 12) != 12) die("write");
        fflush(stdout);

        char buf[32];
        unsigned int i = 0;

        if(write(STDOUT_FILENO, "\x1b[6n", 4) != 4) die("write");
        printf("\r\n");
        fflush(stdout);

        while(i < (sizeof(buf)-1)) {
            if(read(STDIN_FILENO, &buf[i], 1) != 1) die("read");
            if(buf[i] == 'R') break;
            i++;
        }
        buf[i] = '\0';

        if((buf[0] != '\x1b') || (buf[1] != '[')) die("\\x1b[6n read failure");
        if(sscanf(&buf[2], "%d;%d", rows, cols) != 2) die("sscanf(146)");

        cls();
    } else {
        *cols = ws.ws_col;
        *rows = ws.ws_row;
    }
}

void print_char(char c, int x, int y) {
    if((x >= 0) && (y >= 0) && (x < COLUMNS) && (y < ROWS)) {
        output[y][x*2] = c;
    }
}

double deg_to_rad(int deg) {
    return deg*PI/180;
}

void clear_buffer() {
    for(int i = 0;i < ROWS;i++) {
        memset(output[i], ' ', COLUMNS*2);
    }
    output[ROWS-1][COLUMNS*2] = '\0';
}

void print_buffer() {
    for(int i = 0;i < ROWS;i++) {
        puts(output[i]);
    }
}

void print_circle(char body, int r, int center[]) {
    if(r == 0) {
        print_char(body, center[X], center[Y]);
        return;
    }

    int offset[2], prev_offset[2] = {-1, -1};
    double ang = 0, ang_leap;

    ang_leap = deg_to_rad((1*360)/(2*PI*r));

    if(ang_leap > RAD_1) {
        ang_leap = RAD_1;
    } else if(ang_leap == 0) {
        ang_leap = 0.0001;
    }

    while(ang <= RAD_90) {
        offset[X] = round(sin(ang)*r);
        offset[Y] = round(cos(ang)*r);

        if((offset[X] == prev_offset[X]) && (offset[Y] == prev_offset[Y])) {
            ang += ang_leap;
            continue;
        }

        print_char(body, center[X]+offset[X], center[Y]+offset[Y]); // 1st quadrant

        print_char(body, center[X]-offset[X], center[Y]+offset[Y]); // 2nd quadrant

        print_char(body, center[X]-offset[X], center[Y]-offset[Y]); // 3rd quadrant

        print_char(body, center[X]+offset[X], center[Y]-offset[Y]); // 4th quadrant

        prev_offset[X] = offset[X];
        prev_offset[Y] = offset[Y];

        ang += ang_leap;
    }
}

void print_numbers(int r, int center[]) {
    /*
    *      deg_to_rad(360/NUM_OF_NUMBERS) = ang
    *   => deg_to_rad(360/12) = ang
    *   => ang = deg_to_rad(30)
    *
    *
    *      sin(ang) = P/H
    *   =  sin(ang)*H = P
    *
    *   => offset_x = sin(ang)*r
    *      offset_y = cos(ang)*r
    */

    int offset[2];

    for(int i = 1;i <= 12;i++) {
        offset[X] = round(sin(RAD_30*i)*r);
        offset[Y] = round(cos(RAD_30*i)*r);

        if(i >= 10) {
            print_char((i/10)+'0', center[X]+offset[X], center[Y]-offset[Y]);
            print_char((i%10)+'0', center[X]+offset[X]+1, center[Y]-offset[Y]);
        } else {
            print_char(i+'0', center[X]+offset[X], center[Y]-offset[Y]);
        }
    }
}

void print_hands(int r, int center[], struct tm t) {
    int len, offset[2];
    double ang, sin_value, cos_value;
    char body;

    // second hand
    body = '.';
    len = (r*80)/100;

    ang = t.tm_sec*RAD_6;

    sin_value = sin(ang);
    cos_value = cos(ang);

    for(int i = 0;i <= len;i++) {
        offset[X] = round(sin_value*i);
        offset[Y] = round(cos_value*i);

        print_char(body, center[X]+offset[X], center[Y]-offset[Y]);
    }

    // minute hand
    body = '*';
    len = (r*65)/100;

    ang = deg_to_rad((t.tm_min*6)/*+(t.tm_sec/10)*/); // seconds adjustement causes confusion

    sin_value = sin(ang);
    cos_value = cos(ang);

    for(int i = 0;i <= len;i++) {
        offset[X] = round(sin_value*i);
        offset[Y] = round(cos_value*i);

        print_char(body, center[X]+offset[X], center[Y]-offset[Y]);
    }

    // hour hand
    body = '@';
    len = (r*40)/100;

    ang = deg_to_rad((t.tm_hour*30)+(t.tm_min/2)+(t.tm_sec/120));

    sin_value = sin(ang);
    cos_value = cos(ang);

    for(int i = 0;i <= len;i++) {
        offset[X] = round(sin_value*i);
        offset[Y] = round(cos_value*i);

        print_char(body, center[X]+offset[X], center[Y]-offset[Y]);
    }
}

struct tm *get_time() {
    time_t seconds = time(NULL);

    if(seconds == -1) {
        perror("error while calling function time()");
        return NULL;
    }

    struct tm *tm = localtime(&seconds);

    if(tm == NULL) {
        perror("error while calling function localtime()");
        return NULL;
    }

    return tm;
}

int print_clock() {
    int center[] = {COLUMNS/2, ROWS/2};

    print_circle('.', CLOCK_RADIUS, center);
    print_numbers(CLOCK_RADIUS, center);

    t = get_time();
    if(t == NULL) {
        return 1;
    }

    print_hands(CLOCK_RADIUS, center, *t);

    print_char('@', center[X], center[Y]);

    return 0;
}

void print_centered(int col_size, char *str) {
    int str_len = strlen(str);
    int start_pos = col_size-(str_len/2);
    for(int i = 0;i < start_pos;i++) {
        printf(" ");
    }
    printf("%s", str);
}

int main() {
    get_window_size(&ROWS, &COLUMNS);
    if(ROWS > COLUMNS/2) {
        COLUMNS -= 2;
        COLUMNS /= 2;
        ROWS = COLUMNS;
    } else if(COLUMNS/2 > ROWS) {
        ROWS -= 2;
        COLUMNS = ROWS;
    }
    output = malloc(sizeof(char*)*ROWS);
    for(int i = 0;i < ROWS;i++) {
        output[i] = malloc(sizeof(char)*((COLUMNS*2)+1));
    }
    CLEAR_TERMINAL_SCREEN();

    while(!kbhit()) {
        MOVE_TO_HOME();

        clear_buffer();

        if(print_clock()) {
            return 1;
        }

        print_buffer();

        print_centered(COLUMNS, asctime(t));

        usleep((1000*1000)/FPS);
    }

    for(int i = 0;i < ROWS;i++) {
        free(output[i]);
    }
    free(output);

    return 0;
}

Quando compilo o programa com gcc clock.c -lm -g, e o executo com gdb ./a.out, permito gdbo download de informações de depuração de https://debuginfod.ubuntu.com. Eu defino o ponto de interrupção em line 175(que usa sina função), então entro stepe vejo este erro:

Breakpoint 1, print_hands (r=17, center=0x7fffffffda20, t=...) at clock.c:175
175             sin_value = sin(ang);
(gdb) step
__sin_fma (x=0.83775999999999995) at ../sysdeps/ieee754/dbl-64/s_sin.c:201
Download failed: Invalid argument.  Continuing without source file ./math/../sysdeps/ieee754/dbl-64/s_sin.c.
201     ../sysdeps/ieee754/dbl-64/s_sin.c: No such file or directory.

A meu ver, ele falha ao baixar as informações de depuração para sina função aqui. Eu tentei pesquisar na internet para perguntas semelhantes, mas não consegui encontrar nada semelhante.

Qual é o problema aqui com o meu gdbe como posso corrigi-lo?

debugging
  • 1 respostas
  • 15 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve