Adding to the workspace (.sh)

Hello, could you please help me with one problem? I would like to add one application to the workspace, but the fact is that it starts with a .sh script. So I don’t understand how to add this to the workspace.

script path:
/home/user/Downloads/clion-2021.1.3/bin/clion.sh

assign [class=“???”]

If it’s a shell script, you can launch it through a terminal. Let’s say you use alacritty. Then you can do this:

bindsym $mod + somekey exec --no-startup-id alacritty --class="IDENTIFIER" -e "/path/to/your/script.sh"

assign [class="IDENTIFIER"] $workspace_name

You can replace IDENTIFIER with anything you like, the important thing is for it to be unique. Also, please note that only the application itself determines if you are allowed to change the WM_CLASS attribute. So if you use something other than alacritty as your terminal emulator, you have to go through the man page of your preferred terminal emulator to see if its possible.

If your terminal emulator doesn’t have a -class or --class option, then you have to look for other ways. Setting the title of the terminal window is possible. If nothing else works, you have no choice other than to set the attribute of the window using xdotool. You can write a shell script to do that (let’s call it set_clion_class.sh):

#!/usr/bin/sh

#First you need to get the process id (PID) of the program you launched. 
#You can achieve this with the pidof command
name_of_program="clion" 
pid=$(pidof $name_of_program)

#now set the WM_CLASS
xdotool search --pid $pid set_window --class "your-preferred-name"

#Note: My memory of xprop is a bit rusty, so be sure to read the documentations and man pages to check the details.

After that, you simply have to chain the script you want to launch with the shell script to alter the WM_CLASS attribute, like so:

bindsym $mod+somekey exec --no-startup-id /home/user/Downloads/clion-2021.1.3/bin/clion.sh ; /path/to/set_clion_class.sh
assign [class='your_preferred_name'] $workspace_name

Example, if you want to assign htop to a particular workspace, using the method above, you do this:

bindsym $mod + h exec --no-startup-id alacritty --class="Htop" -e "htop"
assign [class="Htop"] $workspace_name
4 Likes

also if no sure of name use xprop . it give all info

3 Likes

@someone

Yes. Like @Shjim said, xprop is a useful tool. Just launch xprop from the terminal and click on the window of interest. xprop will print out a list of attributes associated with that window on your terminal.

3 Likes

Appreciate the help, solved!

@someone
go to the post that most helped you fix the problem.
at the bottom of the post will be the “Solution” icon. Click on that icon, and that will trigger the forum software to “do it’s thing”.

This will aide further searches for this solved problem.

Thanks

Pudge

These two solutions have helped me to the fullest. Although I used the first answer option, most likely the faster solution would be to use xprop.

Then since you are the OP of this Topic, the “Solution” icon should be present on all posts. Pick one and click on it. If for some reason, the “Solution” icon is not visible, click on the three horizontal dots … and click on “Solutiopn”.

Pudge

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.