How to track whether a key is pressed when executing a Bash script?

Have a simple bash script (run from the context menu Caja filemanager )
need right in it ,the script check the conditions
if nothing is selected/highlighted output
if you had selected a directory and pressed Ctrl_Right to perform команду1 (change owner recursively)
if you were selected directory/file to execute команду2 (change of owner only for the dedicated)
otherwise perform команду3

that's what I with grief in half, piled ,BUT plugging in this line
if [[ echo "$key" == "key[105]=down" ]] replaced tricked :)
but what I can't figure out why not change the owner,what's wrong?through the console all the rules.



# find id of the active Claudia
idkb=$(xinput list | grep -Po 'AT Translated Set 2 keyboard\s+id=\d+' | grep -Po '\d+$')

# and assigned to the variable key value of the pressed button
#"key[105]=down", down , "key[105]=up" - NOT down .
key=$(xinput --query-state $idkb | grep -Po '105]=.*' )

# if script execution key was pressed Ctrl_Right 
#ie the previous line/command returned: "key[105]=down"
if [ $key != "105]=up" ]

# print message and run a command recursively change the user
sudo chown-R $user $path && notify-send "recursively"

# if not , i.e. returned (should return "key[105]=up" ) ,
# then change the user only for the selected file/directory
sudo chown $user $path && notify-send "one" 
notify-send-t 3000 "owner of path: $path has become $user keycod key: $key" ;
March 23rd 20 at 19:40
1 answer
March 23rd 20 at 19:42
xneur AddAction
I found a solution ,but where I went wrong,
if not difficult Glenlee code I added to the question after PS

later/tomorrow see what you mean xneur AddAction

my job is to make the same script run on different
depending on the pressed/not pressed Ctrl - zac commented on March 23rd 20 at 19:45
so no I will not be satisfied
first click bind is not a question,but they all needed.
secondly, I have this problem:
gXNeur crashes if I have ,in addition to the default in system settings is configured :
Caps - switching of keyboard layout
Numeric keypad Delete behavior - Legacy key with comma (always a comma on the numeric keyboard = this helps me.)
on 18минте everything worked ,moved on the 19th and that's such a pain in the ass purchased.
So I'm all set up how I want ,and later included these two options (above)
icon of system tray is missing but everything works as it should ,so I'm really not bothered
to display/switch the missing native/system icon.
and the main/hot team I hang in xbindkeys
I then downloaded all the code in your question.
how to get press,I understand, but stuck on a very simple
why doesn't sudo chown-R $user $path through the script.
last night killed and now 4 hours torturing his bad head :) - zac commented on March 23rd 20 at 19:48
@zac, I so curly, the decision is simply the result of failed tasks. Maybe go back to where you started to catch mouse button pressed when you run the scripts and see if there was a more simple and natural ways? - tate.Klin commented on March 23rd 20 at 19:51
something there - fabian.Gra commented on March 23rd 20 at 19:54
I don't understand why when you substitute a variable $path in the command
I'm talking about
notify-send "recursively" && sudo chown-R $user $path
if you write the path /blah/blah/blah works

although notificant this variable reads and writes a file at that path changed
Yes, and we worked the script a couple of times while I was invented :)
then something broke and I don't know

I don't this script is NOT important/needed
the main thing I figured out right in the script, you can connect hotkeys - zac commented on March 23rd 20 at 19:57
@zac, leave the hope, it's just a small fry imagines himself a fighter for justice and trying to Troll me.
I still don't understand what the hell you are going ahead across the mainstream and heroically overcome the impossible. If you need the choice in the script - there is a standard dialog.
And bikes with which you are running, even on the same computer via SSH will not work. On the neighboring would not work at all. - tate.Klin commented on March 23rd 20 at 20:00
I want a little to learn
no,not to write your next great Axis, or super-Puer game
just want to be able to write a necessary "crutch" - zac commented on March 23rd 20 at 20:03
@zac, trying to reach such a low level as the keyboard, with such as bash, you are bound to get a chain of spikes, crumbling from the first sneeze.
The invention of the atomic Bicycle is very exciting, but it is futile and even harmful. And mainstream IT is still the decision task is simple and obvious (i.e. commonly used) means, and the "spikes on the knee" - bad practice. - tate.Klin commented on March 23rd 20 at 20:06
well, I now thump to go?
so everything is health pracital
I for myself -- to Mosh not dried up :) - zac commented on March 23rd 20 at 20:09
@zac, and you should not think that the decision in mainstream style is definitely the easy way. On the contrary, often need to force myself to break away from your favorite bike to step on the throat of the Song of the Crutch and to make a human being ;)
In this case, you are all in the lower level of the blind, shamans, and not really getting useful knowledge. If you do have an interest With, standards and system calls waiting for you ;) - tate.Klin commented on March 23rd 20 at 20:12
I was too late to go to - to die soon.:)
With can be pulled,but a bluff with tyzh the programmer?
on Vkontakte and Facebook I don't wipe them,
in toys I do not play ,films not normally released,
and the old ones probably have already revised.
I used to repair electronics hunted,and now there is no health (eyes,hands shaking)
for the past ten years as I have a monitor and nothing heavier than a Cup in his hands did not take :) - zac commented on March 23rd 20 at 20:15
@zac, twenty years ago I come across on the Internet one bike, to find not taken, retell in your own words.
The young Prince met on the hunt, the old fisherman was so impressed by his wisdom that made him his vizier. The vizier was served at the court for forty years. And the Prince was killed in his first military campaign. So, at the meeting, the Prince was very old - he could live for several months, and the fisherman was still very young - he was ahead forty years of service. - tate.Klin commented on March 23rd 20 at 20:18
I'm not in a hurry - zac commented on March 23rd 20 at 20:21

Find more questions by tags Linuxbash