Difference between pages "Sed" and "Find out a window's application"

From Linuxintro
(Difference between pages)
imported>ThorstenStaerk
 
imported>ThorstenStaerk
(Created page with "If you have a window on your desktop and you want to know which application it belongs to, open a console and enter the command xprop you will get an output like [...] WM_...")
 
Line 1: Line 1:
[[sed]] is a [[command]] to edit a text stream in [http://en.wikipedia.org/wiki/Batch_mode batch mode].
+
If you have a window on your desktop and you want to know which application it belongs to, [[open a console]] and enter the command
 
+
xprop
For example,
+
you will get an output like
  sed "s/a/o/"
+
[...]
Will read your input (stream) from the keyboard and '''s'''ubstitute every '''a''' by an '''o'''.
+
  WM_CLIENT_LEADER(WINDOW): window id # 0x3200001
 
+
'''_NET_WM_PID(CARDINAL) = 7661'''
= Usecases =
+
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
* Remove leading white space
+
WM_CLIENT_MACHINE(STRING) = "tweedleburg"
sed 's/^[ \t]*//'
+
WM_NORMAL_HINTS(WM_SIZE_HINTS):
* Replace strings
+
                program specified minimum size: 0 by 0
  sed -e "s/cgi?\([0-9][0-9]*\)/cgi@\1.html/g" myfile.html > index.html
+
                window gravity: NorthWest
* Insert a line a beginning of file
+
  WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
  sed -i '1i <This is now at the first line>' <filename>
+
  '''WM_CLASS(STRING) = "Navigator", "Firefox"'''
* Replace several newlines by one
+
[...]
sed 's/\ \{1,\}/\ /g'
+
From this you can tell that the application identifies itself as "Navigator", "Firefox". If this is too unsure for you, have a look at the process ID PID, which is 7661 in the above example:
* change the protocol for a given port in /etc/services:
+
  ps -A |grep 7661
  sed -ri "s/.{16}3200/sapdp00 3200/" /etc/services
+
  7661 ?        01:00:53 firefox-bin
 
+
By this you see that the [[process]] that manages the Window is number 7661 and called firefox-bin.
= Limitations =
 
You cannot use sed to delete linebreaks, for this you must use tr.
 
 
 
= See also =
 
* [[Bash Skripting Tutorial]]
 
* [[piping]]
 
* [[grep]]
 
* [[regex]]
 

Revision as of 08:28, 16 June 2012

If you have a window on your desktop and you want to know which application it belongs to, open a console and enter the command

xprop

you will get an output like

[...]
WM_CLIENT_LEADER(WINDOW): window id # 0x3200001
_NET_WM_PID(CARDINAL) = 7661
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "tweedleburg"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified minimum size: 0 by 0
                window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Navigator", "Firefox"
[...]

From this you can tell that the application identifies itself as "Navigator", "Firefox". If this is too unsure for you, have a look at the process ID PID, which is 7661 in the above example:

ps -A |grep 7661
 7661 ?        01:00:53 firefox-bin

By this you see that the process that manages the Window is number 7661 and called firefox-bin.