Programming :: Get Pixel Color From Screen In Bash Script?
Nov 25, 2010I would like to get the pixel color from screen at (320,240) and if the color = 0xFFFFFFFF , i would like to execute a command.
View 3 RepliesI would like to get the pixel color from screen at (320,240) and if the color = 0xFFFFFFFF , i would like to execute a command.
View 3 RepliesI am writing a bash script that utilizes the output of another script (which I will refer to as script#2.) Script#2 is not owned by me, I cannot modify it. All of the output from script#2 is blue, which makes it difficult for me to read.
I would like to have the output of it changed to grey. Is there a way I can do that in my script? A command I can pipe the output to?
Edit: One other question related to this. I put a trap function in my script that works well. Script#2 essentially runs a tail -f. When I ctrl+c to stop it, it stops script#2 and never calls the trap in my script. Is there any way I can work around that?
I've been trying to figure out a way to more easily color text in Perl like I do on Bash on a Linux box. In bash, what I'll do is set color variables up to equal the escape sequence, then echo out with escape seqeunces to print it exactly how I want it. Typically I'll want a character or a word in a different color, not the whole line. For example
echo -n -e "My face is turning ${RED}red${UNCOLOR} like a lobster." In Perl with the term::ANSIColor module, it seems to just do a line. Am I being dense? Is there a way that I can do it like I do it in BASH that's fairly easy to read after the fact?
(bare with me as I am sort of new with scripting) I am trying to figure out how to run a script that does a basic chkconfig and to get only those services that are running, but changing the color of "on" to red in my output file. Here is what I am working with so far:
Quote:
#/bin/bash
RED=$(tput setaf 1)
BLK=$(tput setaf 0)
[code]....
*I had to substitute a "-" and <colon_symbol> for ":" in front of the on's, because the forum thought they were smiley faces (i.e. n) how to make the "on" to be red while the rest of everything remains in black text. I have been trying to read up on sed and awk, but it is still pretty much a mystery to me right now. There will be other things in the output file that I wouldn't want a rogue "on" to be in red, so just the instances of "on" in that one chkconfig return.
I have a problem for which I imagined a radical solution. Okay, I have a script that uses Alltray's "menu" feature as an interface. It's working greatly, EXCEPT sometimes lxpanel (the panel and tray of LXDE) has a hiccup and restarts, at which point the alltray menu is still running, but the icon is gone from the tray.
I want to somehow test the screen for the existence of a color, a color that is likely only to exist in the icon I've chosen for the chat menu. If the color exists on my screen, then the script can continue to do nothing, but if the color doesn't exist, then that means the alltray icon with my custom icon has disappeared, at which point I should have my bash script close the alltray process and start it again.
How to accomplish the checking of my screen for the existence of a particular color? To simplify, I already have simple screenshot scripts (scrot is good for it), so it would be fine if I could simply analyze an image.
I am using the screen app, and have set bce to on, and issued the following commands to set my background and foreground color: tput setab 4; clear; tput setaf 7; clear;
This temporarily sets everything properly on my screen. However, when I issue any commands that change or set their own background color (for example, when I issue an "ls" command with colorized output), the background color gets lost for any new output and I have to reissue the commands listed above in order to retrieve my background color.Ideally I'd like to keep my background color when issuing these commands, as it serves as a good way to remind me of what environment I am currently issuing commands in.
How to determine the best sub pixel order of the screen?
View 2 Replies View RelatedI was wondering if theres a commandline prog that could give me an 'X' (like xprop does) so that I can point to a particular pixel and it give me the X and Y cordinates of that pixel?
View 2 Replies View RelatedWhat is your favorite 256-color color scheme for vim?
View 6 Replies View RelatedI am trying to scroll text from a text file across a wx.panel. This is the code so far:
Code:
def scrolling(self, text, rate):
def scroll(): charList = []
dc = wx.ClientDC(self.panel_1)
open_text = open(text, "rb")
my_text = open_text.read()
charList.append(my_text) open_text.close()
x,y = self.panel_1.GetClientSizeTuple()
while 1: for z in charList: for r in range(2000):
dc.DrawText(z,x-r,0) time.sleep(rate) dc.Clear()
net3 = threading.Thread(target=scroll)
net3.setDaemon(1) net3.start()
It scrolls but I am guessing where the range is (2000). I need to be able to determine the total number of pixels that the text in the file is. Is there a python way to determine this?
I'm making a game with the xlib library. What I want to do is to know if the character is standing on a trap or something else.
So far I've solved that using the coordinates but when I draw circles or stuff not shaped like a rectangle it gets to hard to make the game exact.
So what I'm asking for is if there is some kind of function in the xlib that tells you which color a pixel has. Because then it'd be much easier.
I've searched but I haven't been able to find anything good. I found XGetPixel() but that appears to work only with images, maybe I can make my window to be an "image"?
I have a bash script that I want to be running on a "clean" screen, but when the script finishes/exits I want to see what was previously on the screen. Any thoughts? The "Clear" command does not enable me to get the information back, and the "Screen" Command runs the program in the original window, so you see nothing until the new screen is exited.
View 4 Replies View RelatedI was attempting to change the bash shell color prompt on my RHEL / CentOS 5 server. When I login as my user account on my server I can see my 'PS1':
Code:
[carlos@srv1 ~]$ echo $PS1
[u@h W]$
I want to change my PS1 to:
PS1='[e[1;32m][u@h W]$[e[0m] '
When I look in ~/.bashrc, I don't see my 'PS1' line so I am confused and wondering how I do this on RHEL / CentOS systems.
This works (meaning it changes color) from CLI...echo -e 'e[1;36m' testCyanBut if I put that same exact line in a script, the result is not colored, and it displays the actual command on screen like this...-e 'e[1;36m' testCyanThe script is obviously executing. Why isn't it interpreting the backslash command in the script?
View 2 Replies View RelatedIs there a place in my 10.04 OS that tells me the meaning of the colors of files? I have a folder that I moved to my home directory when i upgraded from 9.10 to 10.04. In that folder was a .tar.gz file that was green - I then deleted that file and ran another compression command - same files, same everything, but when I ran it this time, it is now red. Any ideas. I'd like to know what the color indication is on any given file.
View 2 Replies View RelatedI got a good one!I colorized my prompt as follow; Green for normal user, Red for root:
Root .bashrc:
PS1=e[0;31m[ ][u@h:w][!]\$ e[m"
User .bashrc:
PS1="e[0;37m[ ][u@h:w][!]\$ e[m"
Which gives:
[Code]...
When in the interactive envirment, my Input and Output are all mess-up. So i want to color the Input and Output with two different colors.. so i can figure them out..
View 1 Replies View RelatedI'm using a logitech quickcam pro 3000 on Ubuntu 10.04.
When I run a simple program with OpenCV to display the output from a camera I get the following output:
Code:
A window still opens with the output from the camera, but it seems very low quality and has far less pixels then it should. The camera built into my computer runs the same program with no problems.
My code for the program is simply:
Code:
One further note to make is that I still have the bad quality and low number of pixels with the logitech even when using webcam program. I can seem to find any drivers to update or anything though.
I am getting more and more comfortable working with the shell, thus I would like to change its prompt color to my liking, as it will be easier for me to distinguish commands vs. outputs.
I've read a couple of instructions of how to change the .bashrc file and am familiar with what the codes in PS1 mean. Except, this file can be intimidating to newbie eyes.
Where exactly on the file is it that I need to make the change?
Here is what I am trying to do. I would like my prompt to like exactly like the prompt I use in Backtrack - which consist in two different colors, one for the host and another for the pwd. Here is what the Backtrack .bashrc file looks like:
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.
# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man:/usr/local/share/man:/usr/bin/man:/usr/share/man
export HOSTNAME="`cat /etc/HOSTNAME`"
[Code]....
I also read that in order to have the same results when I log in as root, I will have to copy the modified .bashrc file into /root
I have a dell inspireon 1501 with Ubuntu 10.04 on it. Sometimes but not always when I boot up I will see colored stripes on the screen that don't go away. The only way to get rid of them is too close the lid of the laptop then open it up again. After I open the lid the stripes go away. Any way to get RID of the stripes?
AMD Sempron 1.8
1.45 GB ram
ATI Xpress video Card
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies View Relatedsimple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
I have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
I'm using xterm/screen/vim, and set them up to 256 color mode. Everything went well, except when background color for the theme I choose is not black.
Here's the theme I use in this example:[URL].. Here's the situation: as long as I only use vim, the background is well rendered, meaning everything is grey in vim background. But when I try this with screen, the background is back to black, and only the text get some kind of highlight with the background color.Here are the magical lines I added to screenrc:
Code:
term screen-256color
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=E[48;5;%dm:AF=E[38;5;%dm'
# Erase background with current bg color. Not needed if TERM=screen-256color
defbce "on"
Colors are well rendered in 256 color, I only have a problem with this background. Anyone knows how to 'fix' this?
I have a dell inspireon 1501 and everytime I try to install a version of ubuntu above 9.10 I get colored stipes on the screen. How do I fix this. The dell laptop has a ati Xpress1150 card in it. It came in the laptop stock.
View 2 Replies View RelatedI dual boot Opensuse and Windows 7.
Both OS install correct graphic driver.
But I find that windows 7 display better color than opensuse,
you can feel the different by eyes.
Why?
I use ssh via KDE 4.4.3 konsole to connect to a 2.6.28-18-generic Ubuntu SMP machine,on which I use vim 7.2 and screen 4.00.03jw4. Within a screen session, the background color persists on the screen session even after closing vim. I dont know if this is a konsole or bash or screen or vim colorscheme problem.
View 1 Replies View RelatedI've coma across a problem I have not been able to solve myself. Is there a function in the linux API similar to GetConsoleScreenBufferInfo() on Windows? refer to: http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
I only need to get the current color settings of the active terminal.
Problem appears every time I leave my computer for a while and my screen turns off because of inactivity. Then after screen starts again, my desktop looks like it lost color depth. I can see wallpaper that consists of big blocks of color tones instead of being smooth. Temporary I had to disable blank screen during inactivity in Power management settings. I have installed:
Ubuntu 10.10 x86_64
kernel 2.6.35-27-generic
GNOME 2.32.0
My graphics card:
ATI Radeon HD 5470 512MB
ATI/AMD FGLRX driver installed