Can root commands be done by conky? [SOLVED]

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Can root commands be done by conky? [SOLVED]

Post by Koentje »

What zcot said.. and also, if you have 2 commands that do the same thing, then time them and see which one is the fastest. time <command>


And for the script i gave you, remove the >> "$tmpfile" behind the echo's and you get direct output.
Also if you look closely in the script you see that it needs a tempfiles folder to work..

Code: Select all

echo -e "$line1"
echo -e "$line2"
echo -e "$line3"
echo -e "$line4"
echo -e "$line5"
echo -e "$line6"
echo -e "$line7"
echo -e "$line8"
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

Code: Select all

#!/bin/bash

dump="./tempfiles/dmidecode.dump"
tmpfile="./tempfiles/mem.tmp"

sudo dmidecode --type memory > "$dump"

line1=$(cat "$dump" | grep "Number Of Devices" | sed 's/^[ \t]*//')
line2=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Size:"{print "Size:", $2; exit}')
line3=$(cat "$dump" | grep "Maximum Capacity" | sed 's/^[ \t]*//')
line4=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Type:"{print "Type:", $2; exit}')
line5=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Speed:"{print "Speed:", $2" "$3; exit}')
line6=$(cat "$dump" | grep -m1 "Configured Voltage" | sed 's/^[[:blank:]]*//')
line7=$(cat "$dump" | awk '/Memory Device/ {flag=1; next} flag && $1=="Form" && $2=="Factor:" {print "Form Factor:", $3; exit}')
line8=$(cat "$dump" | awk '/Memory Device/,/Type Detail/ {if ($0 ~ /Type Detail/) {print "Type Detail:", $3; exit}}')  #'

echo -e "$line1" > "$tmpfile"
echo -e "$line2" >> "$tmpfile"
echo -e "$line3" >> "$tmpfile"
echo -e "$line4" >> "$tmpfile"
echo -e "$line5" >> "$tmpfile"
echo -e "$line6" >> "$tmpfile"
echo -e "$line7" >> "$tmpfile"
echo -e "$line8" >> "$tmpfile"
I'm trying the best I can to understand the above code without the benefit of knowing the language. It appears to create a directory called "tempfiles" and put the files "dmidecode.dump" and "mem.tmp" into them but I searched from root directory for both "tempfiles" and "dmidecode.dump" Tempfile dirs only existed in:

/home/logansfury/.conky/3months/tempfiles
/home/logansfury/.conky/conky-usage/tempfiles
/home/logansfury/.conky/spectrum-equalizer-v1.4/tempfiles

I expected to see one in the Minimalis Conky directory generated by this script. The dmidecode.dump wasn't found at all. Looking at the code I it seems that the echos are printing lines sequentially to $tmpfile, but $tmpfile isn't found anywhere on the system either.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Can root commands be done by conky? [SOLVED]

Post by Koentje »

Logansfury wrote: Mon Mar 25, 2024 5:22 pm I'm trying the best I can to understand the above code without the benefit of knowing the language.
Or you are bullshitting me now, or you were bullshitting me then.. but you recently tried to convince me you made a bash script with some complicating calculations from mm to inch. viewtopic.php?p=2446511#p2446511
In comparison to this script, you can make this one on a 'My First Sony'! So stop saying you don't understand..
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

Koentje wrote: Mon Mar 25, 2024 6:59 pm
Logansfury wrote: Mon Mar 25, 2024 5:22 pm I'm trying the best I can to understand the above code without the benefit of knowing the language.
Or you are bullshitting me now, or you were bullshitting me then.. but you recently tried to convince me you made a bash script with some complicating calculations from mm to inch. viewtopic.php?p=2446511#p2446511
In comparison to this script, you can make this one on a 'My First Sony'! So stop saying you don't understand..
I never said I wrote that conversion script, I got it from an online resource. What I had said was it was my first successful time setting up a separate bash script outside of a conky config and calling it from within conky with the ${exec ./hdmi.sh}

I'm sorry If I didn't make that clear but I certainly aren't trying to deceive you after all the time you've spent helping me. I am honestly at a loss for how to get the bash script you provided to display in conky. I'm sure I could do so with instructions as to what scripts to create or what scripts to edit.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

What zcot said.. and also, if you have 2 commands that do the same thing, then time them and see which one is the fastest. time <command>


And for the script i gave you, remove the >> "$tmpfile" behind the echo's and you get direct output.
Also if you look closely in the script you see that it needs a tempfiles folder to work..
CODE: SELECT ALL

echo -e "$line1"
echo -e "$line2"
echo -e "$line3"
echo -e "$line4"
echo -e "$line5"
echo -e "$line6"
echo -e "$line7"
echo -e "$line8"
Somehow I managed to miss this entire post. I just realized it was there. I made a tempfiles directory inside .conky/Minimalis\ Conky and I did the edit of the bash file:

monitors.sh

Code: Select all

#!/bin/bash

dump="./tempfiles/dmidecode.dump"
tmpfile="./tempfiles/mem.tmp"

sudo dmidecode --type memory > "$dump"

line1=$(cat "$dump" | grep "Number Of Devices" | sed 's/^[ \t]*//')
line2=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Size:"{print "Size:", $2; exit}')
line3=$(cat "$dump" | grep "Maximum Capacity" | sed 's/^[ \t]*//')
line4=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Type:"{print "Type:", $2; exit}')
line5=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Speed:"{print "Speed:", $2" "$3; exit}')
line6=$(cat "$dump" | grep -m1 "Configured Voltage" | sed 's/^[[:blank:]]*//')
line7=$(cat "$dump" | awk '/Memory Device/ {flag=1; next} flag && $1=="Form" && $2=="Factor:" {print "Form Factor:", $3; exit}')
line8=$(cat "$dump" | awk '/Memory Device/,/Type Detail/ {if ($0 ~ /Type Detail/) {print "Type Detail:", $3; exit}}')  #'

echo -e "$line1"
echo -e "$line2"
echo -e "$line3"
echo -e "$line4"
echo -e "$line5"
echo -e "$line6"
echo -e "$line7"
echo -e "$line8"
and my conky.conf to execute it:

Code: Select all

conky.config = {
    alignment = 'middle_middle',
    gap_x = 30,
    gap_y = 15,

    background = true,
    border_width = 1,
    cpu_avg_samples = 2,
    default_color = 'gray',
    default_outline_color = 'black',
    default_shade_color = 'white',
    color0 = '#ffffff',
    color1 = '#ff0000',
    double_buffer = true,
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = true,
    draw_shades = false,
    extra_newline = false,
    font = 'Neon 80s:size=10',

    minimum_height = 410,
    minimum_width = 380,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_console = false,
    out_to_ncurses = false,
    out_to_stderr = false,
    out_to_x = true,
    own_window = true,
    own_window_class = 'Conky',
    own_window_transparent = true,
    own_window_argb_visual = true,
    own_window_type = 'desktop',
    own_window_hints ='undecorated,sticky,skip_taskbar,skip_pager,below',
    show_graph_range = false,
    show_graph_scale = false,
    stippled_borders = 0,
    uppercase = false,
    use_spacer = 'none',
    use_xft = true,
}

conky.text = [[
${execpi 86400 monitors.sh}

]];
the tempfiles dir exists, the bash script has been given permission to run. I think I have followed all the directions but I have no display on screen
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

nnnnnnnnnnnnnnnnnnngh >.<

I should have had my caffine before I started editing.

${execpi 86400 ./monitors.sh} is working a hell of a lot better than ${execpi 86400 monitors.sh}

I finally have it working, and I see its the memory info not monitors. Going to begin replacing files now.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

This is displaying in all white text, and the Minimalis I am fitting it into is formatted with red colored categories and white colored values. I just tried a few edits following the format of the existing code (used parenthesis instead of curly bracers) and they arent affected the display at all:

I started with line1=$(goto 35)$(color red)$(cat "$dump" | grep "Number Of Devices" | sed 's/^[ \t]*//') this had no effect and I was afraid the color code may have had a missing equalls sign or quotations so I eliminated it and tried line1=$(goto 35)$(cat "$dump" | grep "Number Of Devices" | sed 's/^[ \t]*//') but this still didnt move the position of the text at all. And I have absolutely no idea how to or where to put the white color command in for the values.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

I just tried editing from within the conky.conf and had mixed results:

Code: Select all

conky.text = [[
${goto 35}${color1}${exec ./memory.sh}
${color1}${goto 35}RAM : ${color0}${mem}/${memmax} ${alignr}${memperc}% ${membar 6,100}
${color1}${goto 35}SWAP: ${color0}${swap}/${swapmax} ${alignr}${swapperc}% ${swapbar 6,100}

${color1}${goto 35}Network Status» ${hr}
]];
this has turned all the text red, and only indents the top line 35 characters to the right. How would I get the goto 35 to effect each line and how on earth do I make the values white instead of red?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

I got a breakdown of the code from an online resource, and found a spot where I could brute force an edit. I have spacing now that approximates the ${goto 35} command, but the formatting and color still doesn't match my conky. This is one column of all red text and what it is meant to replace is a two column section with red and white text mixed.

Code: Select all

#!/bin/bash

dump="./tempfiles/dmidecode.dump"
tmpfile="./tempfiles/mem.tmp"

sudo dmidecode --type memory > "$dump"

line1=$(cat "$dump" | grep "Number Of Devices" | sed 's/^[ \t]*//')
line2=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Size:"{print "       Size:", $2; exit}')
line3=$(cat "$dump" | grep "Maximum Capacity" | sed 's/^[ \t]*/       /')
line4=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Type:"{print "       Type:", $2; exit}')
line5=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Speed:"{print "       Speed:",  $2" "$3; exit}')
line6=$(cat "$dump" | grep -m1 "Configured Voltage" | sed 's/^[[:blank:]]*/       /')
line7=$(cat "$dump" | awk '/Memory Device/ {flag=1; next} flag && $1=="Form" && $2=="Factor:" {print "       Form Factor:", $3; exit}')
line8=$(cat "$dump" | awk '/Memory Device/,/Type Detail/ {if ($0 ~ /Type Detail/) {print "       Type Detail:", $3; exit}}')  #'

echo -e "$line1"
echo -e "$line2"
echo -e "$line3"
echo -e "$line4"
echo -e "$line5"
echo -e "$line6"
echo -e "$line7"
echo -e "$line8"
this was all I could come up with, adding 8 spaces before each line prints. It's a couple of pixels off of where ${goto 35} placed the first line.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Can root commands be done by conky? [SOLVED]

Post by Logansfury »

I found out online how to combine lines in the echo statement. I still cant figure how to get offset or goto to work, or the second color:

Code: Select all

#!/bin/bash

dump="./tempfiles/dmidecode.dump"
tmpfile="./tempfiles/mem.tmp"

sudo dmidecode --type memory > "$dump"

line1=$(cat "$dump" | grep "Number Of Devices" | sed 's/^[ \t]*//') 
line2=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Size:"{print "       Max Size per Device]:", $2; exit}')
line3=$(cat "$dump" | grep "Maximum Capacity" | sed 's/^[ \t]*/       /')
line4=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Type:"{print "       Memory Type:", $2; exit}')
line5=$(cat "$dump" | awk '/Memory Device/{flag=1; next} flag && $1=="Speed:"{print "       Speed:",  $2" "$3; exit}')
line6=$(cat "$dump" | grep -m1 "Configured Voltage" | sed 's/^[[:blank:]]*/         /')
line7=$(cat "$dump" | awk '/Memory Device/ {flag=1; next} flag && $1=="Form" && $2=="Factor:" {print "       Form Factor:", $3; exit}')
line8=$(cat "$dump" | awk '/Memory Device/,/Type Detail/ {if ($0 ~ /Type Detail/) {print "       Type Detail:", $3; exit}}')  #'

echo -e "$line1              $line4"
echo -e "$line2     $line8"
echo -e "$line3            $line5"
echo -e "$line7        $line6"
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
Post Reply

Return to “Compiz, Conky, Docks & Widgets”