Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I properly use python to access system commands and make my script work?
    primarykey
    data
    text
    <p>So the script I have is to have a larger dzen2 outputting conky on the screen when I have less than 3 workspaces open on i3 and shrink it back down when I have more than 3 workspaces open. Here's the script dzresize.py:</p> <pre><code>import subprocess def main(): #gets the number of workspaces from i3 status = subprocess.check_output(["i3-msg", "-t", "get_workspaces"]) #puts status in a list status_list = list(status) #sets name to 0 name = 0 for i in status_list: if i == "name": name +=1 #counts the amount of name in status_list if len(status_list) &lt;=3: #if the workspaces are less than or equal to 3, expands dzen2 with conky output subprocess.check_output(["conky", "-d", "-c", "~/bin/conkyrc_cli|dzen2", "-fg", "#666666", "-bg", "#333333", "-ta", "left", "-w", "725", "-x", "54", "-y", "750"]) else: #if the workspaces are greater than or equal to 3 run the minimal smaller size dzen2 with conky subprocess.check_output(["dzconky.sh"]) main() </code></pre> <p>Here's the output of the scrip:</p> <pre><code>Conky: forked to background, pid is 18519 </code></pre> <p>sample output (if I have 2 workspaces open) for i3-msg -t get_workspaces:</p> <pre><code>i3-msg -t get_workspaces [{"num":1,"name":"1","visible":false,"focused":false,"rect":{"x":0,"y":0,"width":1366,"height":749},"#output":"LVDS1","urgent":false},{"num":2,"name":"2","visible":true,"focused":true,"rect":{"x":0,"y":#0,"width":1366,"height":749},"output":"LVDS1","urgent":false}] </code></pre> <p>Relies on i3, dzen2 and the files ~/bin/conkyrc_cli and ~/bin/dzconky.sh. ~/bin/conkyrc_cli:</p> <pre><code># Conky configuration for Dzen2, to be piped into i3bar ############################################## # Settings ############################################## background no out_to_console yes update_interval 1.0 total_run_times 0 use_spacer none TEXT ^fg(\#6699cc)Processor^fg()^fg(green)${cpu cpu0}.00%^fg()^fg(white)|^fg(\#6699cc)Memory^fg()^fg(green)${memperc}.00%^fg()^fg(white)|^fg(\#6699cc)Root^fg()^fg(green)${fs_used_perc /}.00%^fg()^fg(white)|^fg(\#6699cc)Home^fg()^fg(green)${fs_used_perc /home}.00%^fg()^fg(white)|^fg(\#6699cc)Temperature^fg()^fg(green)${hwmon temp 1}'C^fg()^fg(white)|^fg(\#6699cc)Dn^fg()^fg(green)${downspeedf wlan0}KiB^fg()^fg(white)|^fg(\#6699cc)U^fg()^fg(green)${upspeedf wlan0}KiB^fg() </code></pre> <p>~/bin/dzconky.sh:</p> <pre><code>#!/bin/sh exec conky -d -c "$HOME/bin/conkyrc_cli" | dzen2 -fg "#666666" -bg "#333333" -ta left -w 607 -x 188 -y 750 &amp; exit 0 </code></pre> <p>Edit: updated to code to reflect new changes and new output</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload