dumpsys window windows | grep -E 'mCurrentFocus' command is not giving me any result - adb

I am giving dumpsys window windows | grep -E 'mCurrentFocus | mFocusedApp' command in the command prompt and it is not giving any results.enter image description here

On my Android 11 device, using dumpsys window windows doesn't give the currently focused window. Instead one has to do:
dumpsys window displays | grep -E 'mCurrentFocus|mFocusedApp'
I think a solution that works on all devices is:
dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'
(dumpsys window dumps information about all the subtopics, including windows and displays).

Remove the extra spaces:
dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

Use this code.
dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'

For windows you can easily find out app package and app activity below this command: open cmd in your PC
adb devices
adb shell dumpsys window | find "mCurrentFocus"

Related

Opening File with emacsclient from windows

I try to open a File from within Windows10 in an emacsclient running on wsl2/Debian.
Upon startup I launch wsl/debian, X410 as X-server and the emacs daemon.
I can start a new emacs frame with emacsclient with the following startclient.bat:
#echo off
debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; emacsclient -c; pkill '(gpg|ssh)-agent'; fi;"
Then I created a shortcut so I can open a new emacs frame from the taskbar. To my surprise it works quite smoothly... so far. However, I can not figure out how to open a file with the emacsclient from within windows explorer.
I guess I would need to pass an argument to the emacsclient -c in the bat file, but how do I do this?
EDIT:
by doing the following:
debian.exe run "if [ -z \"$(pidof emacsclient)\" ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0; emacsclient -c "%1"; pkill '(gpg|ssh)-agent'; fi;"
I can open a file with emacsclient with:
startclient.bat file.txt
However when using open with the path to the file is messed up
instead of
/mnt/c/Users/path/to/file
I get
/mnt/c/Windows/system32/C:\Users\path\to\file
How would I go about passing the correct path as variable?
Not quite sure where the /mnt/c/Windows/system32/ is coming from, but you can convert the C:\Users\path\to\file into /mnt/c/Users/path/to/file by surrounding the %1 argument with wslpath, as in something like:
emacsclient -c "$(wslpath '%1')"

Create a bat file for git-bash script

Hi all. I gave a git-bash installed and want some automatisation. I've got a .bat file, which I want to run as
some.bat param | iconv -cp1251 > l.log | tail -f l.log
And I want to run it not in WinCMD but in git-bash shell - tell me plz how to do it?
Git bash on windows uses BASH. You can use bash to create a quick script that can take in parameters and echo them so that you can pipe them to your next utility.
It could look something like this
File: some.sh
#!/bin/bash
#Lots of fun bash scripting here...
echo $1
# $1 here is the first parameter sent to this script.
# $2 is the second... etc. $0 is the script name
then by setting some.sh as executable
$ chmod +x some.sh
You'll then be able to execute it in the git-bash shell
./some.sh param | cat ... etc | etc...
You can read about bash programming
I'd reccomend looking at some bash scripting tutorials such as this one

How do I run a terminal command at the same time as executing a C program from terminal

I have a C program executable. I will run a terminal command at the same time as I run the program and wonder how I would do that?
./program | ps -l -u ${USER} | grep info
I put in my username for USER but I get:
Usage: ps [options]
Try 'ps --help ' or 'ps --help
' for additional help text.
For more details see ps(1).
Don't know what I do wrong?
answering your question as stated in header you want to run
./program & ps ...
You probably want to run your ./program in the background as you grep the output from ps:
./program & ps -l -u ${USER} | grep info
the & puts ./program in the background where as | is used to pipe the output of one command to another

Copy output of the program to the screen and also to the file

I have written client-server application in C. I run the server in linux.
I need to do simple logs of what server do. I print it to the screen.
Please how can I copy output of the screen also to the file.
Thx
You can use the tee command as:
./server_program | tee server.log
You can use the tee command:
$ ./program | tee log.txt

How to make objdump -D only display specific function in Windows?

I want to display the machine code of a specific function. For example, in Linux I would enter:
objdump -D x.out | grep -A20 main.:
What would the equivalent be in Windows?
What would the equivalent be in windows?
Off the top of head, you just save the output into a file:
objdump -D x.out > x.out.dump
then open the file (x.out.dump) in the text editor of choice.
On Windows to peek into the object code I find myself mostly using GUI debuggers. Windows is not very command-line friendly environment. Otherwise, you might want to install the CygWin, start bash in terminal or the cmd.exe and use the grep as if you were under Linux.

Resources