Closed thyeun closed 2 years ago
I've never used i3, so I'm not really fimilar with it.
You can use wmctrl to do this. install wmctrl
and try this commands. wmctrl -d (to list all the workspaces) wmctrl -s (to switch focus on workspaces) wmctrl -l (to list out all the occupied workspaces)
all window manager handle workspaces differently, if you want more help can you share output of above commands.
I dont know how to using wmctrl
.
below is my i3 script for the workspace, by get understand from your bspwm workspace script, but some how is not working.
#!/bin/sh
workspaces() {
ws1=1
ws2=2
ws3=3
ws4=4
ws5=5
ws6=6
ws7=7
ws8=8
ws9=9
# Unoccupied
un="0"
# check if Focused
f1=$(i3-msg 'workspace 1;[class="tmux"]focus' | grep "$ws1" )
f2=$(i3-msg 'workspace 2;[class="Brave"]focus' | grep "$ws2" )
f3=$(i3-msg 'workspace 3;[class="Thunar"]focus' | grep "$ws3" )
f4=$(i3-msg 'workspace 4;[class="Geany"]focus' | grep "$ws4" )
f5=$(i3-msg 'workspace 5;[class="vlc"]focus' | grep "$ws5" )
f6=$(i3-msg 'workspace 6;[class="Tauon Music Box"]focus' | grep "$ws6" )
f7=$(i3-msg 'workspace 7;[class="Gimp-2.10|Inkscape"]focus' | grep "$ws7" )
f8=$(i3-msg 'workspace 8;[class="Teams"]focus' | grep "$ws8" )
f9=$(i3-msg 'workspace 9;[class="Lxappearance"]focus' | grep "$ws9" )
# check if Urgent
o1=$(i3-msg 'workspace 1;[urgent="latest"]' | grep "$ws1")
o2=$(i3-msg 'workspace 2;[urgent="latest"]' | grep "$ws2")
o3=$(i3-msg 'workspace 3;[urgent="latest"]' | grep "$ws3")
o4=$(i3-msg 'workspace 4;[urgent="latest"]' | grep "$ws4")
o5=$(i3-msg 'workspace 5;[urgent="latest"]' | grep "$ws5")
o6=$(i3-msg 'workspace 6;[urgent="latest"]' | grep "$ws6")
o7=$(i3-msg 'workspace 7;[urgent="latest"]' | grep "$ws7")
o8=$(i3-msg 'workspace 8;[urgent="latest"]' | grep "$ws8")
o9=$(i3-msg 'workspace 9;[urgent="latest"]' | grep "$ws9")
windows=$(i3-msg -t get_tree | jq --argjson visible "$(i3-msg -t get_workspaces | jq -c '[.[] | select(.visible) | .id]')" -c '. | .nodes[] | .nodes[] | select(.type=="workspace" and .id == $visible[]) | .nodes' | jq length)
if [ $windows -gt 0 ]; then
echo false
else
echo "(box :class \"works\" :orientation \"h\" :halign \"center\" :valign \"start\" :space-evenly \"false\" :spacing \"10\" (button :onclick \"i3-msg 'workspace $ws1'\" :class \"$un$o1$f1\" \"\") (button :onclick \"i3-msg 'workspace $ws2'\" :class \"$un$o2$f2\" \"\") (button :onclick \"i3-msg 'workspace $ws3'\" :class \"$un$o3$f3\" \"\") (button :onclick \"i3-msg 'workspace $ws4'\" :class \"$un$o4$f4\" \"\") (button :onclick \"i3-msg 'workspace $ws5'\" :class \"$un$o5$f5\" \"\" ) (button :onclick \"i3-msg 'workspace $ws6'\" :class \"$un$o6$f6\" \"\") (button :onclick \"i3-msg 'workspace $ws7'\" :class \"$un$o7$f7\" \"\") (button :onclick \"i3-msg 'workspace $ws8'\" :class \"$un$o8$f8\" \"\") (button :onclick \"i3-msg 'workspace $ws9'\" :class \"$un$o9$f9\" \"漣\"))"
fi
}
workspaces
i3-msg -t subscribe -m '["window", "workspace"]' | while read -r _ ; do
workspaces
done
i manage to get the workspace number up, but the color either for focus or urgent, it still wont change accrodingly
Really sorry to disturbing you
Okay, I didn't know i3 can already do this.
Colors are coming from class
if I run workspace script in terminal i get output like this. (box :class "backgrnd" :orientation "h" :spacing 5 (button :onclick "bspc desktop -f 1" :class "011" "") (button :onclick "bspc desktop -f 2" :class "02" "") (button :onclick "bspc desktop -f 3" :class "0" "") (button :onclick "bspc desktop -f 4" :class "0" "") (button :onclick "bspc desktop -f 5" :class "0" "")) (box :class "backgrnd" :orientation "h" :spacing 5 (button :onclick "bspc desktop -f 1" :class "01" "") (button :onclick "bspc desktop -f 2" :class "022" "") (button :onclick "bspc desktop -f 3" :class "0" "") (button :onclick "bspc desktop -f 4" :class "0" "") (button :onclick "bspc desktop -f 5" :class "0" ""))
for workspace 1 if window is not occupied o1 and f1 is empty so output class will be "0" if window is occupied f1 will be empty so output class will be "01" if window is focused nothing will be empty so your output is gonna be "011" this is same for each workspace. then setting colors for those output in eww.scss file you have to set this for each possible condition.
you can run your script in terminal, see what output you're getting, check output is matching with style in eww.scss
One more thing if you have even single error in eww.scss file the colors won't work. for this try isolating your workspace widget. make new eww.scss and eww.yuck file which only have workspace stuff open that widget window see if everything works correctly then merge it with bar.
ok, i think i should not assign any class into my i3-msg class, see what class will be the output, so that it can match with 0
, 01
and 011
thanks!!!!
yeaa,
let me know if it worked.
@niraj998 i give up, back to polybar. and thank you so much and sorry for disturb you.
Happy to help, it's little easier to do with, wmctrl if you decide to give another try.
honestly, even I don't like how It's done. it's running soo many commands just to get workspaces properly.
i'm zero to wmctrl, i3wm dont have bspc to do things, i3-msg sometime have to link up alot of things to figure out work or not work, and i been wasted few weeks on this, really given up.
Now i'm combine the polybar with eww-bar, (not perfect, because when fullscreen polybar still overlap)
Any how your bspwm workspace script are nice. i really like it, that inspiration me to try eww-bar.
I gave i3 a try and I got it to work.
you can find script here along with what you need to have in eww configs https://github.com/niraj998/niraj998/tree/main/assets/dots/i3workspace
@niraj998 you so pro, it look like a reverse if there was an open workspace we cant set it into true
, because an open workspace also consider as occupied. this is the part i confused on i3.
thank you so much!!!!
@niraj998 do you using Thunar
as file manager? i notice the urgent
for Thunar
will never change others color no matter which workspace i assign it to. For others no issue at all no matter where i put/assign it to others workspace. (dont know is Thunar issue or i3 workspace issue)
just want to confirm that it is not my system issue, if you encounter the same issue
do you mean shortcut for thunar, at the start ? it won't change colours because it's image and not icon
In my i3, the workspace assign Thunar
is $ws3
and inside eww-bar workspace script (button :onclick \"i3-msg 'workspace $ws3'\" :class \"$works3\"\"\") \
The right side of the chrome icon, is for Thunar
, it wont change to red color (i already set to red inside scss file)
Others no issue, only Thunar
wont change color
okay, can you show me what you have in scss file
Others got no issue the color will change once in urgent
, only Thunar
wont change, it is nothing related with scss, everything fine.
scss code
// Workspaces
.works {
font-family: "Iosevka Nerd Font";
padding: .7rem 1.5em .0 .6rem;
font-size: 0.8em;
}
.unoccupied {
color: $gray;
}
.occupied {
color: $white;
}
.focused {
color: $yellow;
}
.urgent {
color: $red;
}
if you using Thunar
in your try out i3wm, than you can reproduce it also, even inside polybar, it wont change, others no issue inside polybar too.
okay, I'm not sure why this is. the color must be comming from somewhere. you can check whole scss file see where is yellow color and change that see if it changes color. if it do. rename that class everywhere in yuck and scss.
Or are you fimiliar with gtk themes ? you can run this command eww -c /path/to/your/ewwfiles inspector it'll open window where you can check where is color comming from
@niraj998 You confused me, i already mention, others application when in urgent status, it will show red color, only Thunar do not show out red color, so it wont be wrong on scss file, because i can reproduce the same things on polybar too
I don't use i3 so I can't reproduce this same error. so what I said and saying is based on the speculation only.
this is what I assume happening it's yellow, because of two things
one i3 is treating urgent thunar window as focused. I don't know why, and you should run i3-msg command when there's thunar urgent window, to see if that's the case.
second, if you don't define any style for class in whole hierarchy. it'll show white color. and the fact it's yellow is it's picking up something. this is also what I was referring to in my previous comment. to find out what styling is being applied. if you find what it's picking. you'll also know why is it yellow.
@niraj998 Question is, all others application will show red
, only Thunar
do not show red
, this is why i mentioned that it is nothing to do with scss
. because if others also happen like Thunar
, than i will assume that scss
might have a issue on that (like: class define twice or something wrong on the color define, but in scss
, if something wrong, the whole eww-bar
wont appear).
And i can reproduce the same error in polybar
.
Anyway i have file in to i3 github
and polybar github
, see what been happen. from what i see it, should error on i3
or Thunar
. Because the client.urgent
color are define in i3 config file
.
And sorry for trouble you, just to let you know i facing it and might happen to you too, that why i commented here.
Okay, I didn't know it's also happening in polybar.
my guess was it's something problem with ewwbar. so my previous two comments applies to diagnosing any issues in bar. if it's also happening in polybar then I'm not really sure why it's happening.
goodluck finding I guess. and thanks for using my scripts.
@niraj998 happy using your script :)
Sorry for asking this, is that a way to do the same in i3wm based on your eww bspwm workspace script?
because in i3wm i didnt see any occupied execute command that can be done in bspwm.
Im stuck that for few weeks.