0

I have 2 linux gnome commands that I would like to merge into one.

One is giving me the title:

gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\)[`gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2`].get_meta_window\(\).get_title\(\) | cut -d'"' -f 2

While the other one is giving me the program name:

gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\)[`gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2`].get_meta_window\(\).get_wm_class\(\) | cut -d'"' -f 2

Now the calls are almost the same yet I fail to retrieve both arguments at once. How can I use both get_meta_window and get_title in one call?

1 Answer 1

0

In bash you can combine two commands using { list; } where list is a list of commands.

Example:

{ echo foo; echo bar; }
foo
bar

You can then filter your concatenated output any way you’d like:

Example 2: (change the newlines to asterisks)

{ echo foo; echo bar ; } | tr “\n” “*“
foo*bar*

Note: spacing is very important. There is a space after the opening { and before the closing }.

Sign up to request clarification or add additional context in comments.

1 Comment

Well. My Problem is that i do not run both commands. I just want to run the first part of the command and the the last two commands. Somehow i can't get it done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.