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?

Silve2611
  • 2,198
  • 2
  • 34
  • 55

1 Answers1

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 }.

Omniver
  • 350
  • 1
  • 3
  • 9
  • 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. – Silve2611 Nov 08 '21 at 10:16