Change ARD settings with bash script?
Hello my fellow friends.
First i am sorry for my bas English but hope you survive.
I was wondering if it was possible to write a script that activated and deactivated ard?
I looked in Controlpanel -> shared and its a option to stop or start a service so it must be possible true terminal or?
Is there anyone that can point me in the right direction?
Thanks.
Thanks.
Something like the page you linked to was what i needed .
But i did figure out how to ask the client for premission to remote controll them so the problem solved itself..
Anyway, thanks Dave.
Similar Messages
-
Change Processor Speed with Apple Script?
Can I use AppleScript to change the Processor Speed in System Preferences/Energy Saver pane?
The background is that my PowerBook G4 is quite noisy when it's running on the highest speed. This is okey during the days but on the evenings and nights I want it silent (but still on), so instead of changing this manually I'm thinking of a Script to trigger this.
Please help. :o)Hi Andreas
yes this can be done using a bit of gui script, the script supplied can be saved as a "application, run only" and activated say from iCal or cron.
"3" is Lowest, so just change the "3" in this line
click menu item 3 of menu 1 of pop up button 1 of tab group 1 of window "Energy Saver"
to 2 or 1 "2" is Highest, "1" is Automatic
and then re-save the script with another name and activate it to change your settings back to where you started.
tell application "System Events"
if not (UI elements enabled) then set UI elements enabled to true
tell application "System Preferences"
set current pane to pane "com.apple.preference.energysaver"
tell application "System Events" to tell process "System Preferences"
set frontmost to true
click radio button "Options" of tab group 1 of window "Energy Saver"
click pop up button 1 of tab group 1 of window "Energy Saver"
click menu item 2 of menu 1 of pop up button 1 of tab group 1 of window "Energy Saver"
delay 0.5
tell application "System Events"
if (name of processes) contains "System Preferences" then tell application "System Preferences" to quit
end tell
end tell
end tell
end tell
Budgie -
[solved] Segmentation fault with bash script
I have a bash script that checks if it has to do something, if not it sleeps 15 secs and checks again. It works great except that after ~6hrs of just checking and sleeping it seg faults. I upped the stack limit with ulimit -s and it goes ~12hrs before it seg faults. I have a similar script that I have been using for ages that works for 24hrs no problem and I can't pinpoint where the problem is.
The check it does is to see if a file exists, if it's empty and if not, read the first line of a file and do some date comparisons. It doesn't matter if the file is empty or not the seg fault always happens.
Here's the seg fault causing script - it starts at the bottom
#!/bin/bash
# User defines
declare -i DVB_DEVICE_NUM="0"
declare CHANNELS_CONF="${HOME}/Mychannels.conf"
declare SAVE_FOLDER="${HOME}/TV/tele"
declare SCHED_FILE="$HOME/.sched-tv"
declare ZAP_COMMAND="tzap"
declare -i SLEEP=15
# Program defines
declare -i DAY="0"
declare -i START="0"
declare -i FINISH="0"
declare CHAN="0"
declare NAME="0"
declare -i MINUTES="0"
declare -i REC_START="0"
declare -i REC_HOURS="0"
declare -i REC_MINS="0"
declare -i howlong="0"
declare -i PIDOF_AZAP=0
declare -i PIDOF_CAT=0
red='\033[1;31m'
green='\033[1;32m'
yell='\033[1;33m'
cyan='\033[1;36m'
white='\033[1;37m'
reset='\033[0m'
function remove_entry {
if [ "$NAME" == "" ]; then
sed "/$DAY $START $FINISH $CHAN/d" $SCHED_FILE > /tmp/dummy
else
sed "/$DAY $START $FINISH $CHAN $NAME/d" $SCHED_FILE > /tmp/dummy
fi
mv /tmp/dummy $SCHED_FILE
function record_entry {
${ZAP_COMMAND} -a ${DVB_DEVICE_NUM} -f ${DVB_DEVICE_NUM} -d ${DVB_DEVICE_NUM} \
-c $CHANNELS_CONF -r ${CHAN} >/dev/null 2>&1 &
PIDOF_AZAP=$!
if [ "$PIDOF_AZAP" == "" ]; then
printf "$red\tError starting ${ZAP_COMMAND}.\n\tFAILED: $CHAN $START\n"
remove_entry
exit 1
fi
printf "$green\tSET CHANNEL$cyan ${CHAN}\n"
REC_MINS=$((${START}%100))
REC_HOURS=0
MINUTES=0
REC_START=$(($START-$REC_MINS))
while [ $((${REC_START}+${REC_HOURS}+${REC_MINS})) -lt $FINISH ]; do
((REC_MINS++))
((MINUTES++))
if [ ${REC_MINS} -ge 60 ]; then
REC_MINS=0
((REC_HOURS+=100))
fi
done
if [ "$NAME" == "" ]; then
declare FILE_NAME="${SAVE_FOLDER}/TV-`date +%Y%m%d-%H%M`-ch.${CHAN}-${MINUTES}.min.mpg"
else
declare FILE_NAME="${SAVE_FOLDER}/TV-${NAME}-${MINUTES}.min.mpg"
fi
dd if=/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} \
of=${FILE_NAME} conv=noerror &
PIDOF_CAT=$!
if (( ${PIDOF_CAT} == 0 )); then
printf "$red\tError Starting Recording.\n\t/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} Unavailable\n"
kill ${PIDOF_AZAP}
remove_entry
exit 1
fi
printf "$yell\tRECORDING TO :$cyan ${FILE_NAME}\n"
sleep ${MINUTES}m
kill ${PIDOF_CAT} && wait ${PIDOF_CAT} 2> /dev/null
# pkill $ZAP_COMMAND # && wait ${PIDOF_AZAP} 2> /dev/null
kill ${PIDOF_AZAP} && wait ${PIDOF_AZAP} 2> /dev/null
printf "$yell\tFINISHED REC :$cyan ${FILE_NAME}\n$reset"
remove_entry
waiting 1
function check_action {
[ -e "$SCHED_FILE" ] || waiting $SLEEP
[ "`cat $SCHED_FILE`" == "" ] && waiting $SLEEP
DAY="0"; START="0"; FINISH="0"; CHAN="0"; NAME="0"
TODAY=`date +%Y%m%d`
NOW=`date +%k%M`
while read -r DAY START FINISH CHAN NAME; do
#printf "$DAY $START $FINISH $CHAN $NAME\n"
break
done < $SCHED_FILE
if [ $DAY == $TODAY ] && [ $START -lt $NOW ]; then
printf "$red\tOld Entry : Removing $CHAN $START\n"
remove_entry
waiting 1
fi
if [ $DAY == $TODAY ] && [ $START == $NOW ]; then
record_entry
else
waiting $SLEEP
fi
function waiting {
howlong=$1
sleep $howlong && check_action
check_action
exit 0
And the script that has been working fine 24hrs at a time
#!/bin/bash
echo alarm uses a twelve hour clock
echo Type the time for the alarm to sound as 00-00-?m
echo e.g. 05-35-pm for 5:35pm :: 05-35-am for 5:35am
read TIME
function play {
A="$(date +%I-%M-%P)"
if [ $A = $TIME ]; then
for i in {1..10}; do
$(aplay -c 1 /home/$USER/alarm/chime.wav); done
exit
else
wait
fi
function wait {
sleep 15 && play
play
I was hoping to have this script idling away in screen with rtorrent, always ready to do something if need be but that's not going to happen unless I can get a clue on what part of the script I need to change to not hit any limits. My websearches are failing me on this...
Last edited by moetunes (2012-06-24 21:41:52)Thanks falconindy. I changed to using a while loop.
#!/bin/bash
set -o nounset
shopt -s huponexit
# User defines
declare -i DVB_DEVICE_NUM="0"
declare CHANNELS_CONF="${HOME}/Mychannels.conf"
declare SAVE_FOLDER="${HOME}/TV/tele"
declare SCHED_FILE="$HOME/.sched-tv"
declare ZAP_COMMAND="tzap"
declare -i SLEEP=15
# Program defines
declare -i DAY="0"
declare -i START="0"
declare -i FINISH="0"
declare CHAN="0"
declare NAME="0"
declare -i MINUTES="0"
declare -i REC_START="0"
declare -i REC_HOURS="0"
declare -i REC_MINS="0"
declare -i howlong=$SLEEP
declare -i PIDOF_AZAP=0
declare -i PIDOF_CAT=0
red='\033[1;31m'
green='\033[1;32m'
yell='\033[1;33m'
cyan='\033[1;36m'
white='\033[1;37m'
reset='\033[0m'
function remove_entry {
if [ "$NAME" == "" ]; then
sed "/$DAY $START $FINISH $CHAN/d" $SCHED_FILE > /tmp/dummy
else
sed "/$DAY $START $FINISH $CHAN $NAME/d" $SCHED_FILE > /tmp/dummy
fi
mv /tmp/dummy $SCHED_FILE
function record_entry {
${ZAP_COMMAND} -a ${DVB_DEVICE_NUM} -f ${DVB_DEVICE_NUM} -d ${DVB_DEVICE_NUM} \
-c $CHANNELS_CONF -r ${CHAN} >/dev/null 2>&1 &
PIDOF_AZAP=$!
if [ "$PIDOF_AZAP" == "" ]; then
printf "$red\tError starting ${ZAP_COMMAND}.\n\tFAILED: $CHAN $START\n"
remove_entry
exit 1
fi
printf "$green\tSET CHANNEL$cyan ${CHAN}\n"
REC_MINS=$((${START}%100))
REC_HOURS=0
MINUTES=0
REC_START=$(($START-$REC_MINS))
while [ $((${REC_START}+${REC_HOURS}+${REC_MINS})) -lt $FINISH ]; do
((REC_MINS++))
((MINUTES++))
if [ ${REC_MINS} -ge 60 ]; then
REC_MINS=0
((REC_HOURS+=100))
fi
done
if [ "$NAME" == "" ]; then
declare FILE_NAME="${SAVE_FOLDER}/TV-`date +%Y%m%d-%H%M`-ch.${CHAN}-${MINUTES}.min.mpg"
else
declare FILE_NAME="${SAVE_FOLDER}/TV-${NAME}-${MINUTES}.min.mpg"
fi
dd if=/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} \
of=${FILE_NAME} conv=noerror &
PIDOF_CAT=$!
if (( ${PIDOF_CAT} == 0 )); then
printf "$red\tError Starting Recording.\n\t/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} Unavailable\n"
kill ${PIDOF_AZAP}
remove_entry
exit 1
fi
printf "$yell\tRECORDING TO :$cyan ${FILE_NAME}\n"
sleep ${MINUTES}m
kill ${PIDOF_CAT} && wait ${PIDOF_CAT} 2> /dev/null
# pkill $ZAP_COMMAND # && wait ${PIDOF_AZAP} 2> /dev/null
kill ${PIDOF_AZAP} && wait ${PIDOF_AZAP} 2> /dev/null
printf "$yell\tFINISHED REC :$cyan ${FILE_NAME}\n$reset"
remove_entry
while true; do
sleep $howlong
howlong=$SLEEP
[ -e "$SCHED_FILE" ] || continue
[ "`cat $SCHED_FILE`" == "" ] && continue
TODAY=`date +%Y%m%d`
NOW=`date +%k%M`
while read -r DAY START FINISH CHAN NAME; do
#printf "$DAY $START $FINISH $CHAN $NAME\n"
break
done < $SCHED_FILE
if [ $DAY == $TODAY ] && [ $START -lt $NOW ]; then
printf "$red\tOld Entry : Removing $CHAN $START\n"
remove_entry
howlong=1
continue
fi
if [ $DAY == $TODAY ] && [ $START == $NOW ]; then
record_entry
fi
done
exit 0
I think that should be ok now. -
Changing SPRM 0 with a script ?
Hi list,
In have searched the archives but I did not found an answer or solution: Is there any way you can change SPRM 0 (menue language) with a script ???
Any help would be great, MichaelHi Chris,
let me first distinguish between a normal menue and a "language menue" which is a menue that is automatically created when you add a second language to the project. Lets say we have got English an Spanish as languages - so in the menue tab you have the option to choose between english and spanish. Now in the scripts I find no way to adress a menue according to it´s language. I can adress the main menue - but wether in english or spanish is no available option. Only choice would be to build a completly seperat menue called "main menue spanish" - okay, I could do that - but what reason is left there for the "language menues" - as nobody sets the DVD player correctly anyway?
But maybe I miss the point - you say "select the correct language based on the users previous selection" - how exactly would you do that? I have stored the users choice in GRPM 0 (eng=0, span=1) and it does change the audiostream and subtitels like expected - how do I change the language ??
michael -
Change Page size with a Script
I have made artwork in Illustrator that is set up as two page spreads on 1 artboard.
I need to convert this to single page spreads.
I.e. So for half the documents, I need to set the anchor point of the document to top left and half the width of the artboard.
For the other half of the documents, I need to set anchor point to to right and half the width.
Is this possible with scripting?
I have look around online to find ways of accessing the document size and anchor point via scripting, but cannot seem to find any resources.
Thanks for any help that can be offered.
Edit: Also is it possible to create a new artboard with a script and assign it a name?here you go, this script splits the artboard in two
// carlos canto
// http://forums.adobe.com/message/5380624#5380624
var idoc = app.activeDocument;
var ab = idoc.artboards[0];
var abBounds = ab.artboardRect;// left, top, right, bottom
var ableft = abBounds[0]; // 0
var abtop = abBounds[1]; // 612
var abright = abBounds[2];
var abbottom = abBounds[3];
var abwidth = abright - ableft; // 792 // width
var abheight = abtop- abbottom; // 0 // height
var half = ableft + abwidth/2;
var abright2 = half;
ab.artboardRect = [ableft, abtop, abright2, abbottom];
var ableft2 = half;
var newAB = idoc.artboards.add([ableft2, abtop, abright, abbottom]); -
LAPTOP Dual Graphics Card CPU scailing (with bash script)
Hey all, basically, getting Arch working with my laptop was a pain due to the lack of power options and graphics control, especially using the open source drivers. My laptop would overheat due to both the dedicated and integrated graphs cards would be running at the same time and my CPUs were running at 100%. After a long while of looking around, I finally found a solution, and being the nice guy I am, I decided to make a script to streamline the process for most people. It mounts the debugging filesystem, adds it to fstab, installs the necessary tools, loads the correct module, and also lets you change power plans, as well as check on battery, graphics card status, and cpu status. this is basically version one so i guess ill add a bit to it over time.
*** MAKE SURE KMS IS ENABLED ON YOUR KERNEL GRUB/SYSLINUX LINE EG: "radeon.modset=1"
******ERROR CHECKING:
if you have the debug fs mounted already, unmount it with umount /sys/kernel/debug
if you get an error modprobing, check what modules are supported from your cpu with ls /lib/modules/$(uname -r)/kernel/drivers/cpufreq/
with the debugging fs mounted, running cat /sys/kernel/debug/vgaswitcheroo/switch to find out what your graphic adapters are named and if needed replace the IGD and DIS with yours
you may have to modify some parts of the program, but i tried my best to make it as easy as I can
Installation:
copy it and save it as foo.sh
chmod 777 it for good measures
RUN AS ROOT
chmod 777 foo.sh
./foo.sh
#! /bin/bash
#By: Dominic dos Santos
#[email protected]
#mount -t debugfs none /sys/kernel/debug --mount debugging fs
#echo"IGD"> /sys/kernel/debug/vgaswitcheroo/switch && echo"OFF"> /sys/kernel/debug/vgaswitcheroo/switch --onboard graphics
#echo"DIS"> /sys/kernel/debug/vgaswitcheroo/switch && echo"OFF"> /sys/kernel/debug/vgaswitcheroo/switch --dedicated graphics
#cpufreq-set -c 3 -g powersave # --powersave cpu freq set
#cpufreq-set -c 3 -g performance # --performance
#cpufreq-set -c 3 -g ondemand #--...
#!!!PLEASE NOTE!!! I am using a quad core laptop, therefore I have the '-c 3' argument. Cores are as such: 0 1 2 3
#Dual core would be '-c 1', 6 core would be 5
echo "RUNNING THIS WIH X RUNNING WILL NOT MODIFY THE GRAPHICS CARD SETINGS"
#checking if debugging fs is mounted, if not, mounting.
if [ -f /sys/kernel/debug/vgaswitcheroo/switch ]; then
echo "DEBUGFS is mounted, continuing wih program"
else
read -p "Press ENTER to mount the debugging directory (REQUIRED)"
mount -t debugfs none /sys/kernel/debug #the mount fs command
echo "Add to fstab?"
read fs
if [ "$fs" == "y" ]; then
echo "debugfs /sys/kernel/debug debugfs 0 0" >> /etc/fstab #add the required line to the fstab
fi
read -p "We are now going to install the cpu drivers and load the required modules."
pacman -S cpufrequtils
echo "Do you have an [a]MD or [i]ntel cpu?" #load the [correct] module now
read input
if [ "$input" == "a" ]; then #AMD
modprobe powernow-k8
elif [ "$input" == "i" ]; then #INTEL
modprobe acpi-cpufreq
fi
echo "REMEMBER TO ADD acpi-cpufreq cpufreq_powersave cpufreq_ondemand cpufreq_performance to your rc.conf beside MODULES=( ****** FOR INTEL CARDS ONLY!"
echo "OR powernow-k8 cpufreq_powersave cpufreq_ondemand cpufreq_performance ****** FOR AMD CPU's ONLY!"
fi
#menu
echo -e "Welcome to my CPU and Videocard Power and Performance Switcherooer"
echo " 1: Powersave"
echo " 2: On Demand"
echo " 3: Performance"
echo " 4: Check Status"
echo "Please select an option"
read input
if [ "$input" = 1 ]; then
#Powersave
#Set CPU to "Powersave", set VGA to onboard and disables one not being used, ie. the dedicated
cpufreq-set -c 3 -g powersave
echo "IGD" > /sys/kernel/debug/vgaswitcheroo/switch
echo "OFF" > /sys/kernel/debug/vgaswitcheroo/switch #the "OFF" infers to cutting the power to the one that isn't selected
elif [ "$input" = 2 ]; then
#On Demand
#Set CPU to "On Demand", set VGA to onboard and disables one not being used, ie. the dedicated
cpufreq-set -c 3 -g ondemand
echo "IGD"> /sys/kernel/debug/vgaswitcheroo/switch
echo "OFF"> /sys/kernel/debug/vgaswitcheroo/switch
elif [ "$input" = 3 ]; then
#Performance
#Set CPU to "Performance", set VGA to the dedicated graphics card and disables the onboard
cpufreq-set -c 3 -g performance
echo "DIS"> /sys/kernel/debug/vgaswitcheroo/switch
echo "OFF"> /sys/kernel/debug/vgaswitcheroo/switch
elif [ "$input" = 4 ]; then # status check
echo " 1: Battery"
echo " 2: Graphics Card"
echo " 3: CPU Info"
read status
if [ "$status" = 1 ]; then #battery
acpi
read -p "Press Enter"
elif [ "$status" = 2 ]; then #battery
cat /sys/kernel/debug/vgaswitcheroo/switch
read -p "Press Enter"
elif [ "$status" = 3 ]; then #battery
cpufreq-info
read -p "Press Enter"
fi
fi
Last edited by imagoose (2012-02-15 22:51:13)Thats great, thank you. I have an older Dell Studio XPS 13 which has NVIDIA Hybrid SLI. Its current power usage in Arch is killing me (about an hour and a half, where as i can get 3-4 hrs in win7). Right now I am doing all the work through the integrated graphics card, per my xorg.conf, but i dont think i've managed to disable the discrete card yet. When I get on the laptop I'll let you know how it goes.
-
[SOLVED] Change environment variables with Shell scripts
How can I change the "BROWSER" environment variable with a shell script; so I can change it on the fly?
Last edited by oldtimeyjunk (2012-10-31 12:57:42)If you just want to do it for BROWSER so that you can change your default web browser on the fly, you could set BROWSER to e.g. ~/bin/mybrowser and create a symlink to the browser you want at ~/bin/mybrowser. Then you could change the symlink at will.
EDIT: man xdg-settings
Last edited by cfr (2012-10-31 02:20:16) -
OSB: Is it possible to change throttling settings with WLST?
Hi all,
I am trying to find a solution to change the throttling settings of a business service with WLST, since it is not possible to set it in the customization file.
I already know the parameter alsbImportPlan.setPreserveExistingOperationalValues(boolean) to preserve or change the operational values with the imported jar file, but I cannot find how to change the parameters separately for a business service (e.g. throttling state, max concurrency).
Thanks for any help,
KatjaHi Fabio,
thanks for your approach. Could you give me some more ideas how to do that exactly? What do you mean with "write a code"? With WLST it does not work, I think. So you mean some code to extract the jar, change the xml, package the jar again and then deploy it? We need the changes at deployment time, because the settings have to be adjusted for the different environments.
Best regards,
Katja -
Help with bash script that fails after suspend to RAM
I have a very simple reminder script that uses an endless loop, sleep and zenity to pop up a reminder every twenty minutes:
#!/bin/bash
while true;
do
sleep 20m
zenity --warning --title="Ergonomics Reminder" --text="Check Posture or Have a Stretch!"
done
However, it does not work as it should after suspending to RAM. I am thinking I need to kill the process and restart it after every suspend, using a "thaw" notice in /etc/pm but if there is an easier way to do it please let me know!I'm doing this for 2 reasons:
- as a scripting exercise
- because the local repo is a shared wordpress mess and people forget to make commits so I'd like a local backup that includes all changes that may not be in github (sadly).
Anyhow, thanks for the input about trap, I'm definitely confused by it's use at this point but have reworked the script without it.
#!/bin/sh
set -e #Exit on any error.
TIME=`date +"%m.%d.%Y@%H:%M:%S"` # Define the TIME variable as today's date and time.
MONTH=`date +"%b"` # Define MONTH as today's month.
FILENAME="backup-$TIME.tar.gz" # Define the filename structure.
SRCDIR="/stuff" # Define folder to backup.
DESDIR="/Backup/$MONTH/" # Define the backup folder location.
LOGFILE="$DESDIR/backup-$TIME.log" # Store the output in a log.
REMOTE=$(git ls-remote -h origin master | awk '{print $1}') # Get commit hash from head of remote master repo (github)
LOCAL=$(git rev-parse HEAD) # Get commit hash from head of server repo (dev/test)
if [[ $LOCAL == $REMOTE ]]; then # If the hashes match
echo "No update required." >> $LOGFILE # Then no pull is needed
else # If the hashes don't match then prepare to run our backup
mkdir -p $DESDIR # Create our directory if it doesn't exist.
echo "Backup started for "$TIME >> $LOGFILE # Make it log what it's doing.
tar -cpzf $DESDIR/$FILENAME $SRCDIR >> $LOGFILE 2>&1 # Perform the backup.
echo "Backup Finished for "$TIME >> $LOGFILE # Log that it's finished.
echo "Preparing for git pull " >> $LOGFILE #Log what we're doing.
cd /stuff >> $LOGFILE 2>&1 # Make sure we're in our repo directory
git pull >> $LOGFILE 2>&1
echo "Git pull completed successfully. " >> $LOGFILE
mail -s "Backup log `date`" [email protected] < $LOGFILE # Email the output to me.
fi -
How to change sharing settings with no video?
I have a macbook pro that does not have any sort of video output. Unfortunately remote login/screen sharing/ssh are all disabled and my version of realvnc is apparently just below the one that works with Lion causing the realvnc window on the remote server to crash when I attempt to connect.
I have hooked the hard drive up to my desktop (windows 7 x64) and have attempt to make the hard drive a vmware installation, but I have not succeeded with that at all. I have made it where I can view the partition in windows using MacDrive, but I am unable to change any of the system files and I'm not even sure if I could change preferences this way.
Is there anything I can do to enable remote login?
Thanks.Hi,
Let me say to start with, that with no video output, some of what I'm about to suggest is guess work.
1. Tap away at f1 as soon as you press the power button - this should launch the Bios Menu.
2. Press the right arrow One time - this should hopefully select the Advanced tab.
3. Press the down arrow twice and hit Enter - this should open the sub-menu for the Primary Video Adapter.
4. Press the down arrow One time and hit Enter - this should select the PCI-E option.
5. Press f10 and hit Enter to save this setting.
Let me know
Regards,
DP-K
****Click the White thumb to say thanks****
****Please mark Accept As Solution if it solves your problem****
****I don't work for HP****
Microsoft MVP - Windows Experience -
Selecting pixels in a picture and changing their color with a script
Hi, I'm brand new to photoshop scripting, and I want to make a script that takes every pixel of a color and replaces it with a new color,
I'm having the hardest time finding any information on the internet on how to do it though.
I do have some background in other coding, so the concepts are not new, just the language and functions.
I know there's tools and filters already, but I want to make a script so I can add features.
Any help would be appreciated.
Thank you!
(P.S. Is there a way to open and read code of a pre-exsisting filter, or is that impossible?)To create your own filters you would need to download the SDK I think you might find an example of a filter.
With Photoshop this might be close...
main();
function main(){
if(!documents.length) return;
var sColour =new SolidColor;
sColour.rgb.hexValue ='245887';
selectColorRange(0,sColour);
try{
var SB = activeDocument.selection.bounds;
}catch(e){return;}
var FillColour =new SolidColor;
FillColour.rgb.hexValue = 'ff0000';
activeDocument.selection.fill(FillColour,ColorBlendMode.NORMAL);
activeDocument.selection.deselect();
function selectColorRange( fuzz, solidColor){
var scaleA = (solidColor.lab.a + 128.5) / 256;
var desc11 = new ActionDescriptor();
desc11.putInteger( charIDToTypeID( "Fzns" ), fuzz );
var desc12 = new ActionDescriptor();
desc12.putDouble( charIDToTypeID( "Lmnc" ), solidColor.lab.l );
desc12.putDouble( charIDToTypeID( "A " ), solidColor.lab.a + scaleA);
desc12.putDouble( charIDToTypeID( "B " ), solidColor.lab.b + scaleA);
desc11.putObject( charIDToTypeID( "Mnm " ), charIDToTypeID( "LbCl"), desc12 );
desc11.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "LbCl" ), desc12 );
executeAction( charIDToTypeID( "ClrR" ), desc11, DialogModes.NO );
Using Christophs suggestion...
//Use 1 pixel to colour
app.activeDocument.colorSamplers.removeAll();
var mySampler = app.activeDocument.colorSamplers.add([new UnitValue(1,'px'),new UnitValue(1,'px' )]);
//Get original colour
var oColour = new SolidColor();
oColour = mySampler.color;
app.activeDocument.colorSamplers.removeAll();
//Select colour
var sColour = new SolidColor();
sColour.rgb.hexValue ='31618f';
activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(sColour,ColorBlendMode.NORMAL);
//Replacement Colour
var rColour = new SolidColor();
rColour.rgb.hexValue ='ff0000';
activeDocument.selection.similar(0, false);
activeDocument.selection.fill(rColour,ColorBlendMode.NORMAL);
activeDocument.selection.deselect();
//Replace original colour.
activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(oColour,ColorBlendMode.NORMAL);
activeDocument.selection.deselect(); -
Hi
There are many times when I need to perform a find or du command on server data hierarchy. Often the recursion goes to many depths so the number of items is too large, i.e. command returns 'Argument list too long'.
So I usually break it into letters, A-C, D-F, etc. However, now I want to write a script to cycle through all top-level folders from A to Z.
I thought this might work
for l in ${ABCDE...}; do
echo $l
done
but it doesn't.
Can anyone please help me with correct syntax?
Cheers
CHow about
<pre> find / -depth 1 -prune -type d</pre>
If I need to process a lot of file names returned by 'find' I tend to use the following approaches:
<pre> find /dir/path -type f -print0 | xargs -0 grep regexp</pre>
where the ls -l is just an example of a shell command and xargs will append file names after the ls command.
<pre> find /dir/path -name "*.c" | while read file
do
echo $file
done</pre>
where the echo is just an example of something to do with the file name. -
Changing many queries with a "script"
A SAP-BI newbee here. I would like to add a characteristic to a cube and have all existing queries filter on this characteristic. Is there a way to create some sort of script to update all queries and automatically insert this filter so that the users don't need to manually touch each query?
Hi Robert,
You can find some sample code and tables here:
Re: Query-InfoObject - Tables
I think there are some more threads out here that have programs modifying the RSZ* tables.
Hope this helps... -
How to send 2 variable value from bash script into java.class
#!/bin/bash
a=10
b=20
echo $a $b | java addition
donehi there,
currently i have a simple java coding ( a + b ). and i m trying to connect with bash script but this bash script coudln't Enter 2nd value (b=20) while i running for it. may i know how do i can Enter 2 value into it?
output from terminal
[seng@localhost java_class]$ bash addition.sh
=======================================================================
simulation 1
Num_a = 10
Num_b = 20
Enter your Num_a : 10
Enter your Num_b : Exception in thread "main" java.lang.NumberFormatException
at java.lang.Integer.parseInt(java.lang.String, int, boolean) (/usr/lib/libgcj.so.6.0.0)
at java.lang.Integer.parseInt(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
at filter_god.GOD(java.util.List, java.util.List, java.lang.String, java.lang.String, int) (Unknown Source)
at filter_god.main(java.lang.String[]) (Unknown Source)
at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
=======================================================================That code will send both numbers on a single line in standard input to the java process. So if the process reads standard input, it will get a single line that has this in it: "10 20".
I'm guessing you're sending that whole line to Integer.parseInt. But a valid number doesn't have a space in the middle.
You should split up the line using String.split. Or use a StringTokenizer. Or a regular expression. Or you can use a java.util.Scanner. Or a java.io.StreamTokenizer. Or maybe some other stuff that has slipped my mind at the moment. -
Change "Location" with a script?
Dear all,
I am working in two different (network) environments and need to change both network settings (proxy, ...) and also computer settings (CUPS server) and some environment variables depending on my physical location. For the latter two I have a little bash script that does that conveniently.
But changing the network always requires a few clicks extra... I was wondering if it was possible to change the network environment ("Location" in the Apple menu) by a script (I tried with AppleScript and Automator but didn't find anything) or to run a script automatically whenever I change the Location. This way I would only have to run either the script or change the Location to adjust all settings.
Can anyone help me here?
Thanks a lot,
LeonardHi Pierre,
Thank you. Your point number 3 was the solution. (I actually wanted to mark your message as "solved"... Now I have marked the question as "answered").
While this works, ideally I would like to have one script that does both the changes to the shell (for this I already have a shell script) and the changes to Mac OS.
On http://developer.apple.com/Mac/library/documentation/AppleScript/Conceptual/Appl eScriptX/Concepts/workwithas.html I found a way to call an AppleScript from the shell (using the #!/usr/bin/osascript interpreter) -- but if I run the script you sent I get
142:166: execution error: No user interaction allowed. (-1713)
In fact I would prefer the script to run without user interaction, i.e. to just put in the name of the location that I want to switch to and not display a selection box. I would then just create two or three scripts for my most frequently used locations. I tried a few variants but I didn't manage to set 'R' which is probably the variable containing the new location to a fixed value. Could I ask you again for help with this?
Thanks again,
Leonard
Maybe you are looking for
-
How To Get User Details in Collaboration ....?
HI, In collaboration i am unable to see the full User Details (Like Mobile Phone Number, E-Mail Address, etc) ,When i was click on user Names. Here i will get full User Details for some users and for some users i did not get(But getting only Last N
-
This is not right: time limit on iMac G5 Repair Program
iMac G5 Repair Extension Program for Video and Power Issues http://docs.info.apple.com/article.html?artnum=302181 The program covers affected iMac G5 computers for up to three years from the original date of purchase. Apple sold iMacs G5 computers th
-
Hi How to create validation for business place in f-43, fb60, f-48 I know t/code GGB0, how to selectPrerequisite, check, message can you please give me details this is very urgent. Thanks in advance.
-
I need to send data from Peoplesoft to MQ series. I have data scattered across two to three components. In order to publish the data from all these components would it be ideal to go for a view or is there any other way?
-
[Solved] kernel configuration
Hi. I want to compile a custom kernel for my laptop. I want to build in kernel my required modules and not compile the modules i do not need(to speed up compilation times ). I want to ask what method did you used(the one who made this) to generate a