Conky widget problem

Novi ste u svijetu Linuxa? Imate hrpu početničkih pitanja?

Moderator/ica: Moderatori/ce

Pravila foruma
PRAVILA ZA NOVE KORISNIKE LINUXA!
Prije otvaranja bilo kakve diskusije svaki novi korisnik u svijetu Linuxa obavezan je učiniti sljedeće korake:
Pročitati ove tekstove iz naše Wikipedije:
- Sve uvodne tekstove Linuxa za početnike (njih 5)
- Sve što trebate znati o radu s diskovima
- Pročitati ovu temu za početnike
- Pokušati pronaći riješenje problema u Enciklopediji znanja

Nakon toga korisnik smije otvoriti temu s naslovom svog problema uz obaveznu naznaku Linux distribucije koju koristi u formi:
[Linux distribucija, broj verzije, grafičko okruženje]: Naslov problema
U prvom postu korisnik obavezno mora odgovoriti na ova pitanja:
- Da li ima instalirane Windowse?
- Što ga je motiviralo na instaliranje i korištenje Linux distribucije?
- Obavezno je potrebno navesti specifikacije hardvera (Ime Laptopa, tip procesora, grafičke i mrežne kartice, količina RAM-a i diska)

Bez učinjenih ovih prvih koraka, na teme se neće odgovarati i one će biti izbrisane s foruma!
Odgovori
Avatar
Tribanj
Postovi: 62
Pridružen/a: 25 kol 2024, 20:38
Spol: M
OS: Linux Mint 22 Cinnamon

Conky widget problem

Post Postao/la Tribanj »

Koristim Conky Manager 2. Sve što treba instalirati da bi ovaja Manager radio, instalirano je.

Koristim widget za Memory koji mi ne pokazuje većinu podataka.

mem.sh

Kod: Označi sve

#!/bin/bash

# Run sudo dmidecode commands and redirect output to mem.txt
> mem.txt
sudo dmidecode --type memory | grep "Number Of Devices" | sed 's/^[ \t]*//' > mem.txt
sudo dmidecode --type memory | awk '/Memory Device/{flag=1; next} flag && $1=="Size:"{print "Size:", $2; exit}' >> mem.txt
sudo dmidecode --type memory | grep "Maximum Capacity" | sed 's/^[ \t]*//' >> mem.txt
sudo dmidecode --type memory | awk '/Memory Device/{flag=1; next} flag && $1=="Type:"{print "Type:", $2; exit}' >> mem.txt
sudo dmidecode --type memory | awk '/Memory Device/{flag=1; next} flag && $1=="Speed:"{print "Speed:", $2" "$3; exit}' >> mem.txt
sudo dmidecode --type memory | grep -m1 "Configured Voltage" | sed 's/^[[:blank:]]*//' >> mem.txt
sudo dmidecode --type memory | awk '/Memory Device/ {flag=1; next} flag && $1=="Form" && $2=="Factor:" {print "Form Factor:", $3; exit}' >> mem.txt
sudo dmidecode --type memory | awk '/Memory Device/,/Type Detail/ {if ($0 ~ /Type Detail/) {print "Type Detail:", $3; exit}}' >> mem.txt
mem_box.lua

Kod: Označi sve

-- Load Cairo functions (explicitly require the library)
require 'cairo'

-- Function to draw a rectangle with rounded corners
function draw_rounded_rectangle(cr, x, y, width, height, roundness, color, thickness)
    -- Set the color for the outline
    cairo_set_source_rgba(cr, color[1], color[2], color[3], color[4])

    -- Set the thickness of the outline
    cairo_set_line_width(cr, thickness)

    -- Calculate the radius of rounded corners based on the given percentage (roundness)
    local radius = math.min(width, height) * (roundness / 100)

    -- Draw the rounded rectangle
    cairo_new_sub_path(cr)
    cairo_arc(cr, x + width - radius, y + radius, radius, -math.pi / 2, 0)  -- Top-right corner
    cairo_arc(cr, x + width - radius, y + height - radius, radius, 0, math.pi / 2)  -- Bottom-right corner
    cairo_arc(cr, x + radius, y + height - radius, radius, math.pi / 2, math.pi)  -- Bottom-left corner
    cairo_arc(cr, x + radius, y + radius, radius, math.pi, 3 * math.pi / 2)  -- Top-left corner
    cairo_close_path(cr)

    -- Stroke the outline to actually draw it
    cairo_stroke(cr)
end

-- Main Conky function
function conky_main()
    if conky_window == nil then return end

    -- Create a Cairo drawing context
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local cr = cairo_create(cs)

    -- Set the color to white with full opacity
    local white = {1, 1, 1, 1}  -- (R, G, B, A)

    -- Set the roundness percentage here (e.g., 20 for 20% rounded corners)
    local roundness_percentage = 10

    -- Draw the rounded rectangle outline
    draw_rounded_rectangle(cr, 2, 2, 254, 280, roundness_percentage, white, 1)

    -- Clean up
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
end
memory.conf

Kod: Označi sve

--[[
Bleys 2024 

]]
conky.config = {
-- — Conky settings

	background = false,

	alignment = 'middle_middle',
	gap_x = -100,
	gap_y = -430,
	minimum_width = 240,
	minimum_height = 420, 

    font = 'Copperplate Gothic Light:size=9',
    use_xft = true,

	border_inner_margin = 10,
	draw_graph_borders = true,
	draw_outline = false,
	double_buffer = true,
	no_buffers = true,

-- Window Settings --
  background = false,
  border_width = 0,
  draw_borders = false,
  draw_graph_borders = false,
  draw_outline = false,
  draw_shades = false,
  own_window = true,
  own_window_colour = '000000',
  own_window_class = 'Conky',
  own_window_argb_visual = true,
  own_window_argb_value = 0,
  own_window_type = 'dock',
  own_window_transparent = true,
  own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
  stippled_borders = 0,

	update_interval = 5,
	total_run_times = 0,

    color0 = 'ffffff',
    color1 = '8dddff',

    lua_load = './transparent-image.lua mem_box.lua',
    lua_draw_hook_post = 'conky_main',	

};
conky.text = [[
${execpi 43200 ./mem.sh}
${lua conky_image ./images/ram8.png 10 14 63 64}${color1}${font Copperplate Gothic Light:size=14}${voffset 20 }${offset 100}Memory${font} 
${voffset 22}${execpi 5 awk 'NR==1 {printf "${color1}Number of Devices: ${color0}${alignr 8} %s\n", $4}' ./mem.txt}
${execpi 5 awk 'FNR==4 {printf "${color1}Memory Type: ${color0}${alignr 8}%s\n", $2; exit}' ./mem.txt}
${execpi 5 awk 'FNR==2 {printf "${color1}Max Size per Device: ${color0}${alignr 8}%s GB\n", $2}' ./mem.txt}
${execpi 5 awk 'FNR==8 {printf "${color1}Type Detail: ${color0}${alignr 8}%s\n", $3}' ./mem.txt}
${execpi 5 awk 'FNR==3 {printf "${color1}Maximum Capacity: ${color0}${alignr 8}%s GB\n", $3 GB}' ./mem.txt}
${execpi 5 awk 'FNR==5 {printf "${color1}Speed: ${color0}${alignr 8}%s %s\n", $2, $3; exit}' ./mem.txt}
${execpi 5 awk 'FNR==7 {printf "${color1}Form Factor: ${color0}${alignr 8}%s\n", $3}' ./mem.txt}
${execpi 5 awk 'FNR==6 {printf "${color1}Configured Voltage: ${color0}${alignr 8}%s\n", $3" "$4}' ./mem.txt}
${color1}RAM : ${color0}${alignr 8}${mem}/${memmax} ${alignr}${memperc}%
${membar 8,236}
${color1}SWAP: ${color0}${alignr 8}${swap}/${swapmax} ${alignr}${swapperc}%
${swapbar 8,236}
]];
To izgleda ovako:

slika

Nakon što widget pokrenem u Terminalu i unesem lozinku dobijem ovo:

slika

slika

U /usr/share/polkit-1/actions napravio sam datoteku pod nazivom 'org.mandak.dmidecode.policy'.

Kod: Označi sve

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>The Mandak Project</vendor>
  <vendor_url>http://www.mandak.org/</vendor_url>
  <icon_name>dmidecode</icon_name>
  <action id="org.mandak.dmidecode">
    <description gettext-domain="dmidecode">Run dmidecode as root</description>
    <message gettext-domain="dmidecode">Authentication is NOT required to run dmidecode as root</message>
    <defaults>
      <allow_any>yes</allow_any>
      <allow_inactive>yes</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/dmidecode</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">false</annotate>

  </action>

</policyconfig>
Linux Mint 22 "Wilma" Cinnamon / Samsung Galaxy A55 5G

MB: ASRock B550M Pro4 / CPU: AMD Ryzen 5 PRO 4650G / GPU int. in CPU Radeon RX Vega 7 Renoir / RAM Memory: Corsair Vengeance LPX 16GB
Avatar
Tribanj
Postovi: 62
Pridružen/a: 25 kol 2024, 20:38
Spol: M
OS: Linux Mint 22 Cinnamon

Re: Conky widget problem

Post Postao/la Tribanj »

Problem riješen. Problem je bio s mem.sh. Sada je sve ispravljeno i izgleda ovako.

Kod: Označi sve

#!/bin/bash


# Sudo password
passw="XXXX"



##################################################################################################

# Temporary file to hold new memory data
temp_file="./mem.txt"

# Collect memory information and write to the temporary file only if theres data
out1=$(echo "$passw" | sudo -S dmidecode --type memory | grep "Number Of Devices" | sed 's/^[ \t]*//')
out2=$(echo "$passw" | sudo -S dmidecode --type memory | awk '/Memory Device/{flag=1; next} flag && $1=="Size:"{print "Size:", $2; exit}')
out3=$(echo "$passw" | sudo -S dmidecode --type memory | grep "Maximum Capacity" | sed 's/^[ \t]*//')
out4=$(echo "$passw" | sudo -S dmidecode --type memory | awk '/Memory Device/{flag=1; next} flag && $1=="Type:"{print "Type:", $2; exit}')
out5=$(echo "$passw" | sudo -S dmidecode --type memory | awk '/Memory Device/{flag=1; next} flag && $1=="Speed:"{print "Speed:", $2" "$3; exit}')
out6=$(echo "$passw" | sudo -S dmidecode --type memory | grep -m1 "Configured Voltage" | sed 's/^[[:blank:]]*//')
out7=$(echo "$passw" | sudo -S dmidecode --type memory | awk '/Memory Device/ {flag=1; next} flag && $1=="Form" && $2=="Factor:" {print "Form Factor:", $3; exit}')
out8=$(echo "$passw" | sudo -S dmidecode --type memory | awk '/Memory Device/,/Type Detail/ {if ($0 ~ /Type Detail/) {print "Type Detail:", $3; exit}}') #'

echo "$out1" > "$tempfile"
echo "$out2" >> "$tempfile"
echo "$out3" >> "$tempfile"
echo "$out4" >> "$tempfile"
echo "$out5" >> "$tempfile"
echo "$out6" >> "$tempfile"
echo "$out7" >> "$tempfile"
echo "$out8" >> "$tempfile"

# Display the content of mem.txt
# cat mem.txt
slika
Linux Mint 22 "Wilma" Cinnamon / Samsung Galaxy A55 5G

MB: ASRock B550M Pro4 / CPU: AMD Ryzen 5 PRO 4650G / GPU int. in CPU Radeon RX Vega 7 Renoir / RAM Memory: Corsair Vengeance LPX 16GB
Odgovori