Skip to content

Instantly share code, notes, and snippets.

@domsson
Created June 26, 2020 12:02
Show Gist options
  • Save domsson/ac47e52aa07ffbb455f013ce2eb86f2f to your computer and use it in GitHub Desktop.
Save domsson/ac47e52aa07ffbb455f013ce2eb86f2f to your computer and use it in GitHub Desktop.
blocks = "desktop | | dummy mem cpu volume updates datetime"
width = 816
height = 14
foreground = #bbbece
background = #2a2c41
line-width = 2
line-color = #7285b7
block-prefix = " "
font = 6x13
label-font = "-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1"
affix-font = "-xos4-terminesspowerline-medium-r-normal--12-120-72-72-c-60-iso10646-1"
[desktop]
command = "bspc query -D -d focused --names"
trigger = "bspc subscribe"
prefix = " "
suffix = " "
underline = true
[dummy]
command = "echo ' '"
background = #bbd984
affix-foreground = #bbd984
affix-background = #2a2c41
[mem]
command = "mem-proc -mus"
live = true
label = "  Mem "
min-width = 5
foreground = #352c38
background = #7ea3fd
label-foreground = #352c38
label-background = #7ea3fd
affix-foreground = #7ea3fd
affix-background = #bbd984
[cpu]
command = "cpu-proc -mus"
live = true
label = "  Cpu "
min-width = 5
foreground = #352c38
background = #c399e7
label-foreground = #352c38
label-background = #c399e7
affix-foreground = #c399e7
affix-background = #7ea3fd
[volume]
command = "volume-pulse -mus -w'muted'"
live = true
label = "  "
min-width = 5
foreground = #352c38
background = #fadb82
label-foreground = #352c38
label-background = #fadb82
affix-foreground = #fadb82
affix-background = #c399e7
[updates]
command = "echo ' 27'"
background = #c399e7
label = "  Updates: "
foreground = #ffffff
background = #f27975
label-foreground = #ffffff
label-background = #f27975
affix-foreground = #f27975
affix-background = #fadb82
[datetime]
command = "datetime -m -f'%a %b %d, %Y %I:%M%p'"
label = "  "
live = true
affix-foreground = #2a2c41
affix-background = #f27975
@domsson
Copy link
Author

domsson commented Jul 9, 2020

Again, I don't know Rust, hence I'm not sure what's happening there. But I assume you're looking at something like printf() or fprintf():

 fprintf(stdout, "%s world!\n", "Hello");

@Joe23232
Copy link

Joe23232 commented Jul 9, 2020

echo '%{B#FF0000}red foo%{B-}' If I wanted to output this exact same command but I don't want to write in shell script, I want to write it in C lang instead, what would be the syntax/command? Sorry for asking so much I am curious to know what would be the most simplest language to use for such a task so I am curious to know its syntax.

@domsson
Copy link
Author

domsson commented Jul 9, 2020

Printing a string to stdout should be similarly simple / performant in pretty much every language under the sun. :) So I wouldn't worry about it. It's the stuff you do to fetch information, like the workspaces, or temperatures, or workload, or whatever, where languages might be different in how easy/hard efficient/inefficient it is. Here is what printing your example string might look like in C:

char color[] = "#FF0000";
char output[] = "red foo";
printf("%%{B%s}%s%%{B-}\n", color, output);

Or, if the "red foo" and color never change, then just:

printf("%%{B#FF0000}red foo%%{B-}\n");

@Joe23232
Copy link

Joe23232 commented Jul 9, 2020

Interesting! However why would you declare color[] as a char, wouldn't it make more sense to declare it as an unsigned 4 byte integer?

@domsson
Copy link
Author

domsson commented Jul 9, 2020

Well, it really depends on the context. But let's say color was an int, then you could probably (I have not tested it) do this:

printf("%%{B#%08X}%s%%{B-}\n", color, output);

@Joe23232
Copy link

Joe23232 commented Jul 9, 2020

Oh I see mate thanks.

@Joe23232
Copy link

Joe23232 commented Jul 9, 2020

Have you used wmctrl package before? I am trying to get the output of the workspace's name but that seems to fail so I was just curious you have some experience with it by any chance?

@domsson
Copy link
Author

domsson commented Jul 9, 2020

I didn't even know about it, but it sounds very useful.

@Joe23232
Copy link

Joe23232 commented Jul 9, 2020

Yeah I was recommended to use it, but yeah I can't get the current work space's name (I can get hte ID).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment