Getting the URL of the current tab from a browser
$ xwininfo -id 0x800003 xwininfo: Window id: 0x800003 "x11 firefox tab at DuckDuckGo - Mozilla Firefox" Absolute upper-left X: 1605 Absolute upper-left Y: 1 Relative upper-left X: 0 Relative upper-left Y: 0 Width: 1978 Height: 1078 Depth: 24 Visual: 0x569 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x800002 (not installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +1605+1 -1025+1 -1025-201 +1605-201 -geometry 1978x1078+1604+0
xprop -id 0x800003
spits more information:
(...) ░░ ░░░ ░ ░░ ░░░░░░░▒▒▒▒░ ░░░░░░░░░▒▒▒░░ ░░░░░░░░░░▒▒░ ░░░░░░ ▒▒▒░ ░░░░░░░░░▒▒▒▒▒ ░░ ▒░░░░░▒▒▒▒▒▒▒▒ ░░ ▒▒░░░░▒▒▒▒▒▒▒▒░░░░ ░ ▒▒▒▒░░▒▒▒▒▒▒▒▒░░░░░░ ░▒▒▒▒░░▒▒▒▒▒▒░░░░░░░ ▒▒▒▒▒▒░▒▒▒▒░░░░░░░ ░▒▒▒▒▒▒▒▒░░░░░░░░░ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ░▒▒▒▒▒▒▒▒▒▒░ ░▒▒▒▒▒▒░ (...) _NET_WM_OPAQUE_REGION(CARDINAL) = _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL _NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 8388613, 8388614 _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x800004 WM_CLIENT_LEADER(WINDOW): window id # 0x800001 _NET_WM_PID(CARDINAL) = 1525016 WM_LOCALE_NAME(STRING) = "en_US.UTF-8" WM_CLIENT_MACHINE(STRING) = "svar" WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified minimum size: 300 by 95 program specified maximum size: 32766 by 32766 program specified base size: 300 by 95 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" WM_ICON_NAME(STRING) = "How to get active google chrome url in the terminal? : commandline - Mozilla Firefox" _NET_WM_ICON_NAME(UTF8_STRING) = "How to get active google chrome url in the terminal? : commandline - Mozilla Firefox" WM_NAME(STRING) = "How to get active google chrome url in the terminal? : commandline - Mozilla Firefox" _NET_WM_NAME(UTF8_STRING) = "How to get active google chrome url in the terminal? : commandline - Mozilla Firefox"
Even the icons! But it doesn’t show the URL… surf
does:
$ xprop _NET_WM_STATE(ATOM) = _NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 0, 0 _NET_WM_DESKTOP(CARDINAL) = 0 WM_STATE(WM_STATE): window state: Normal icon window: <field not available> _NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_CLOSE WM_HINTS(WM_HINTS): Client accepts input or input focus: True Initial state is Normal State. window id # of group leader: 0x4200001 _SURF_URI(STRING) = "http://duckduckgo.com/" _SURF_FIND(STRING) = "" _GTK_THEME_VARIANT(UTF8_STRING) = XdndAware(ATOM) = BITMAP _NET_WM_OPAQUE_REGION(CARDINAL) = 0, 0, 1978, 1078 WM_WINDOW_ROLE(STRING) = "Surf[6]" _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL _NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 69206021, 69206022 _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x4200004 WM_CLIENT_LEADER(WINDOW): window id # 0x4200001 _NET_WM_PID(CARDINAL) = 1637209 WM_LOCALE_NAME(STRING) = "en_US.UTF-8" WM_CLIENT_MACHINE(STRING) = "svar" WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified minimum size: 0 by 0 program specified base 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) = "surf", "Surf" WM_ICON_NAME(STRING) = "[0%] @cgDISVMf:T | " _NET_WM_ICON_NAME(UTF8_STRING) = "[0%] @cgDISVMf:T | " WM_NAME(STRING) = "[0%] @cgDISVMf:T | " _NET_WM_NAME(UTF8_STRING) = "[0%] @cgDISVMf:T | "
Issuing surf -x
makes it echo the window id.
Issuing
xprop -id 14680067 -f _SURF_URI 8s -set _SURF_URI http://duckduckgo.com
should make it go to that URL, if I understood everything correctly, but it does not.
Alternatively, echo "http://duckduckgo.com" | xclip
and then C-p works.