Overwriting "Print Screen" actions in linux without administrative rights [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Disclaimer:
I am a bit of a Linux noob :(
Problem:
I have an interesting problem that I could use some help with. Essentially, I want to overwrite the default actions for the "Print Screen" button in Linux. My reasons for doing so are that I have a homemade graphics card running attached to the computer and I'm trying to make a utility where I can capture what it is outputting to a separate monitor and send it back to the "host" computer. For purposes here, I only want to know: How can I execute a script upon pressing the Print Screen button? Note that I cannot install xbindkeys or any other software. Ideally I would like to be able to run a script to enable this behavior.
Current work-around:
Currently, I have a .bashrc script:
#!/bin/bash
export PATH=/home/username/bin:$PATH
In the /home/username/bin folder I have a script "gnome-screenshot" that, for now, just performs some arbitrary task (it actually does this: "cat /usr/share/icons// > /dev/dsp" -- try it! It's fun!).
I am working on school computers, so I first CTRL-ALT-F5 to open a terminal login, login, then source .bashrc. I then startx -- :1 to start a new X session. Now, if I hit the PrintScreen button, it uses my gnome-screenshot, not the default screencapture program.
Is there anyway to do this without all of the restarting X? In short, is there a way to source my .bashrc script, or otherwise modify my PATH variable, before or while I login?
Another Approach:
I also tried, briefly, to xmodmap and the keycode to execute a script, but couldn't figure out how to tie them together. I know the keycode (111) but can't figure out how to run a script on press. I believe it might be possible to make a sort of binding using this but can't figure out how.
Help!
I'd really appreciate some help or comments!
(Edit): Added Details About Distribution:
cat /etc/redhat-release tells me:
Red Hat Enterprise Linux Client release 5.8 (Tikanga)

xmodmap is not the tool you want; it cannot bind keys to programs, it binds physical keycodes to logical keysyms. XGrabKey(3) is what you're looking for.
Reading your shell dotfiles while starting the X session depends on the exact OS and desktop environment you're using (including version; there are 4 or 5 different ways you might need to use even considering only different Ubuntu versions with their stock desktops).

Related

Installed Go, but command go not found. Does work on one terminal linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I installed go on linux yesterday. It worked fine and downloaded some tools and they worked also. I left the terminal open and when I came back today go stopped working... In the left terminal go works and does everything... But when I open another terminal and type go it said "command go not found" (see screenshot).
Can anyone help me please? I don't know what I did wrong or what went wrong...
Go works on the left terminal, not right...
tl;dr
Add the export command you ran to the $HOME/.bashrc file (preferably at the end).
When you installed go you probably ran the export command to add the location of go binaries to the PATH variable. But here's the thing. The PATH variable is, effectively, reset to the previous value when you open the new terminal. To make it permanent you need to add the command to your shell's rc file.
What's an rc file?
When you open the terminal it uses a rc (short for run commands) file and runs the commands in this file. The name of the file depends on the shell you are using.
If you are using bash, the name would be .bashrc. If you are using zsh, the name would be .zshrc.
You can run echo $PATH in both the terminals and see the PATH variable in which go runs would have the location of go binaries and the other wouldn't.
So to make this permanent, add the export PATH=$PATH:{PATH_GO_BINARIES} to the rc file. And, then, whenever a new terminal is opened, the PATH variable would be updated to contain the location of go binaries.

Edit an applescript file from a linux computer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Though applescript appears to be a scripting language like any other (wikipedia/applescript), for reasons I don't understand it seems these scripts are often saved as binaries. It seems like this isn't an issue for someone working on a Mac with a mac-based text editor that can open these scripts into a plain-text format where they can be edited and read, but for the rest of us, we just see gibberish. For instance, Github has many examples of .scpt files committed to repositories instead of/without the plain-text equivalent (a bit of Googling suggests this would be a .applescript file instead)
Question: Is there an open-source tool that can parse and serialize these binaries so that they can be viewed/edited in a standard plain text editor and saved back as .scpt?
(My context: I'd like to provide a user-friendly, os native button-click way to launch my application on a mac, rather than tell users to open a bash terminal and type stuff.)
Edit I only have access to a linux machine, I don't own a mac.
Instead of trying to create an AppleScript on a non-Mac, what you can do is simply name your shell script file with a .command suffix and make sure that it has execute POSIX permissions for the user. The user can then double-click the file in the Finder to execute your script instead of having to enter Terminal commands.
If you would like to take advantage of AppleScript commands within your shell script file to add some simple GUI functionality, you can use the osascript command.
BTW, for reference: on a Mac the application "Script Editor" (or "AppleScript Editor" on older systems) is generally used to create AppleScripts. It provides several save options - the .scpt binary and .applescript plain text files you noted as well as .scptd script bundles and .app standard, double-clickable applications.

OSX/Linux, slow down the output from terminal [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm printing to screen a long text file that scrolls very very quickly on my screen, is there a way to slow down the scrolling? In other words is there a system setting that controls the speed at which output is displayed to screen (OSX/Linux).
Simple answer: No.
Extended version: There are other solutions. You could pick from one of the following:
Use pipes. Using pipes allows you to redirect terminal output and to review it in your own speed. The appropiate symbol is |. Redirect the output to programs like less ore more. Both allow you to scroll through the output via pressing return, you can exit any time by pressing q. For instance, for handling a long directory listing, you could use
ls | more
Redirect your output into a file. If your output is cached in a file, it's persistent and allows you to open it with an editor of your choice to view (and edit) it. The symbol is >.
touch log.txt # create the file
ls > log.txt
nano log.txt # use nano text editor to view
script allows you to record entire terminal sessoins. This might be an overkill for your use-case, but is really useful. From the man page:
script makes a typescript of everything printed on your terminal. It is
useful for students who need a hardcopy record of an interactive session
as proof of an assignment, as the typescript file can be printed out
later with lpr(1).
Use less to page through files; you can page back and forth, search, etc.
xterm has limited control over scrolling speed; most other terminal emulators have none, because that's the wrong way to step through a file when you can use a program like less to filter the output.

editor in Cygwin [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I had just installed cygwin on my win XP machine, new to unix & learning things...
How can I know which editor had been installed with cygwin installation on my system? none of the editors out of vi, vim, nano, ted, jow etc working...tried using 'notepad' but it saves the file as .txt ....
Also another confusion which I have is, even the files which I have created without shebang line as well as without .sh extension , I am able to execute them when given permission to do so...how can a script be run when I have not added shebang line in that?
I had trouble with this and a few other things in Cygwin. Vim, Emacs, (and many other standard Unix programs) are not installed by default in Cygwin.
You need to run the setup program again (no need to uninstall first), and explicitly add what you want.
I wrote a blog post about this: http://wilsonericn.wordpress.com/2011/08/15/cygwin-setup-gotchas/
The shebang line is not needed if your $SHELL can interpret the script. i.e., if you write a bash script and invoke it through bash, you don't need the shebang line.
To know which editors are installed, run the cygwin setup.exe file again and go through the package list (under the group editors), you may pick additional editors to install too.
If you have other scripts, you should be able to launch most scripts without sheband line in this way:
bash script.sh
tcsh script.csh
python script.py
perl script.pl
etc...
By the way, if you are new to unix, I recommend you get used to an advanced text editor.
I don't want to troll, but using XEmacs or Vim could help you a lot (syntax highlighting, snippet usage for ex.). I have been using Vim for years now, and I would probably not be able to go back to a basic editor...
If you have the disk space I recommend just letting the Cygwin installer have at it and deploy everything .... I am glancing at it every now and then while watching the F1 race. I use a 750GB hybrid flash / spinning disc drive so storage isn't an issue. It is much like the old Red Hat "Kitchen Sink" option with the DVD9 format.
It would be helpful if the Cygwin installer would show the fact it intends to install only 50/2100 packages by default, or if there was a wizard with some useful premix choices (minimal, server, GUI, everything)

in Screen, how do I send a command to all virtual terminal windows within a single screen session? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I know how to create multiple windows within a single screen session, at startup:
But once I have them up and running, is there a way I can have my input be sent to all open windows, not just the one currently in focus?
I found a good tutorial here to do this:
http://blog.cone.be/2009/11/24/gnu-screen-nethack-different-screen-windows-sending-commands-to-all-screen-windows/
From the post:
Once you re used to the multiple windows, you might run into a situation where you want to send a same command to several of these open windows. Screen provides in the “at” command to do this. First you ll need to open command line mode.
C-a : (colon) Enter command line mode.
This way you can type a command once, but you ll still have to enter each separate window. But there is a better way. As an example we ‘ll send “ls -l” to all the windows.
at "#" stuff "ls -l^M"
This command is barely readable, so let's pick it apart! The first part is 'at [identifier][#|*|%] command'. The at command sends the text parameter to all the windows you specified in the identifier. You can match the criteria to either the window name or number with #, the user name with * or the displays, using %. The next part is the command you want to run in the selected windows. We’re using "stuff" to stuff the command we want to execute into the input buffer of the selected windows. Stuff is really straightforward. It simply stuffs the string you gave as a parameter. Next problem is the command. Or rather having it executed! To get screen to put an “enter” after the command, to execute the command, add “^M” at the end. You can do a lot more with this than just sending an ls to the input. Any screen command, like renaming, moving windows around, whatnot .. is available in combination with "at".
Sorry for this belated reply, but tmux might be a better choice for you than screen. In tmux, you have to press: C-b : to enter the command mode and input: setw synchronize-panes (or just setw sync<Tab> using autocompletion). Note that this command enables synchronization between panes (areas of one split screen, visible simultaneously), but not between windows (full, not split, screens).
You may also want to send to selected windows only (multicast).
Convention: Give 1st character of window title the meaning of a broadcast flag. E.g. if title starts with "." then the window listens to broadcast, otherwise it doesn't.
Set titles as needed.
screen -S SessionName -p 0 -X title "remote_0" # window 0: ignore multicast
screen -S SessionName -p 1 -X title ".remote_1" # window 1: listen to multicast
Send contents to listeners with the at command of screen
screen -S SessionName -X at ".#" stuff "date
"
Note: the ending double quote above ensures a ^M to be sent (Cr).
You may enable / disable multicast based on window title this way.

Resources