[KDE 4.9] Using a shell script as a KDE shortcut - Caps Lock Notify

Hi, all
I was trying to create a small script to send a notification if the Caps Lock is active or not. The script works correctly in the terminal, but when I use the script as a shortcut in KDE it does not work ... I simply trigger the shortcut with the "Caps Lock".
Below is the script that I created:
#!/bin/bash
# Send a notification of CAPS LOCK on/off
# Icon used in the notification
icon="/usr/share/icons/NITRUX/devices/48/keyboard.svg"
# verify if the CAPS is on/off
value=$(xset q | grep "LED mask" | sed -r "s/.*LED mask:\s+[0-9a-fA-F]+([0-9a-fA-F]).*/\1/")
if [ "$value" == "0" ]; then
output="Off"
else
output="On"
fi
# Send notification (use Gnome or KDE)
# GNOME
#notify-send -i $icon "Caps Lock $output" -t 1000
#KDE
kdialog --icon $icon --passivepopup "Caps Lock $output" --title "Keyboard" 1
Could someone help me pointing what I'm doing wrong?
Thanks in advance!
EDIT: If I do not use the "caps lock" as a trigger, the script works as it should (I tried using "ctrl + alt + L") ...
Last edited by gustavosg (2012-11-13 00:06:46)

Pajaro wrote:
gustavosg wrote:
Pajaro wrote:try sending the dialog with a delay in background
Hi! Thanks for replying. I've tried the sleep command, still saying that caps is always on (if it is what you mean).
What I meant is to do something like:
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock $saida" --title "Teclado" 1) &
When I use it on the script it just printi "Caps" on the notification, as if it was reading just the first word of the "Caps Lock $saida".
Edited the script to this:
#!/bin/bash
# Manda aviso de CAPS LOCK on/off
# icone pra usar na notificacao
icone="/usr/share/icons/NITRUX/devices/48/keyboard.svg"
# verifica se o Caps esta ligado
valor=$(xset q | grep "LED mask" | sed -r "s/.*LED mask:\s+[0-9a-fA-F]+([0-9a-fA-F]).*/\1/")
if [ "$valor" == "0" ]; then
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock Off" --title "Teclado" 1) &
else
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock On" --title "Teclado" 1) &
fi
# Dispara alerta (usar Gnome ou KDE)
# GNOME
#notify-send -i $icone "Caps Lock $saida" -t 1000
#KDE
#$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock $saida" --title "Teclado" 1) &
cfr wrote:
Maybe you could post the script if you are still having trouble?
Thanks for the info about single key short cuts. I guess it has never occurred to me. (Maybe because on a laptop you can't usually spare a whole key for a single short cut!)
The script is the one in the OP. I'm using a laptop.
EDIT:
Updated OP script to english...
Last edited by gustavosg (2012-11-13 00:07:38)

Similar Messages

  • Sending email attachments using unix shell script

    hi
    I want to send report generated my spooled file as attachment using unix shell script.
    Can somebody help me out ?
    many thanks

    thanks a tonn it worked.
    but i have another issue is it possible to add names in CC also ?
    Also here is my code which spools the output of SP to a txt file. the File name is generated dynamically.
    as shown below:
    I need to send this generated file as attachement.
    how do I do this? Here the shell script
    =========================================================
    #!/bin/sh
    ORA_USER=scott
    ORA_PWD=tiger
    #Get the input parameter
    if [ ! "$1" ]; then
    STR="NULL"
    else
    STR="'"$1"'"
    fi
    #echo "exec pkg1($STR);"
    #Connecting to oracle
    sqlplus -s <<EOF
    $ORA_USER/$[email protected]
    ---sql plus enviornment settings
    set linesize 160
    set pagesize 60
    set serveroutput on size 1000000 for wra
    set feedback off
    set termout off
    column dcol new_value mydate noprint
    select to_char(sysdate,'YYYYMMDDHH24MISS') dcol from dual;
    spool &mydate.report.txt
    exec pkg1($STR);
    spool off
    EOF
    exit
    =========================================================
    the file name will take sysdate as name so that every time a new file will be generated.
    this file I need to send as attachment.
    null

  • Using Power shell script how to hidden SharePoint existing features.

    Hi Firends,
    Using Power shell script how to hidden SharePoint existing features.
    Please help me.
    Thanks,
    Tiru
    Tiru

    The Hidden property is set within the solution, so you would need access to the source code in order to set it.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • How to use "do shell script" when Terminal replies with a prompt?

    Hey all,
    I'm wondering how to properly use "do shell script" when Terminal replies with a question? In this example, I'm building a small tool in AppleScript that will auto-update the Android SDK via command line prompts. The problem is when I tell it to update all ("update sdk --no-ui"), I need to accept licence agreements before it continues, and the amount of licence agreements brought up is different every time.
    So, basically, I'm wondering how to handle a case where "do shell script" encounters a case where Terminal would normally need a user's response to?
    Thanks,
    Behn

    If it is variable number of prompts that is a problem.  Look around hd and figure out how many prompts there will be. Ask around android forum for a bash solution. There are some test case apps that will let you put conditionals on output from running programs.
    # traditional way.  Pipe output to command.
    do script "echo 'ok' | update sdk --no-u"
    Here is the preferred way of getting administrator privileges.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set unixDesktopPath to POSIX path of "/System/Library/User Template/"
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "sudo ls -l  " & quotedUnixDesktopPath with administrator privileges
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run

  • Find & replace part of a string in Numbers using do shell script in AppleScript

    Hello,
    I would like to set a search-pattern with a wildcard in Applescript to find - for example - the pattern 'Table 1::$*$4' for use in a 'Search & Replace script'
    The dollar signs '$' seem to be a bit of problem (refers to fixed values in Numbers & to variables in Shell ...)
    Could anyone hand me a solution to this problem?
    The end-goal - for now - would be to change the reference to a row-number in a lot of cells (number '4' in the pattern above should finally be replaced by 5, 6, 7, ...)
    Thx.

    Hi,
    Here's how to do that:
    try
        tell application "Numbers" to tell front document to tell active sheet
            tell (first table whose selection range's class is range)
                set sr to selection range
                set f to text returned of (display dialog "Find this in selected cells in Numbers " default answer "" with title "Find-Replace Step 1" buttons {"Cancel", "Next"})
                if f = "" then return
                set r to text returned of (display dialog "Replace '" & f & "' with " default answer f with title "Find-Replace Step 2")
                set {f, r} to my escapeForSED(f, r) -- escape some chars, create back reference for sed
                set tc to count cells of sr
                tell sr to repeat with i from 1 to tc
                    tell (cell i) to try
                        set oVal to formula
                        if oVal is not missing value then set value to (my find_replace(oVal, f, r))
                    end try
                end repeat
            end tell
        end tell
    on error number n
        if n = -128 then return
        display dialog "Did you select cells?" buttons {"cancel"} with title "Oops!"
    end try
    on find_replace(t, f, r)
        do shell script "/usr/bin/sed 's~" & f & "~" & r & "~g' <<< " & (quoted form of t)
    end find_replace
    on escapeForSED(f, r)
        set tid to text item delimiters
        set text item delimiters to "*" -- the wildcard 
        set tc1 to count (text items of f)
        set tc2 to count (text items of r)
        set text item delimiters to tid
        if (tc1 - tc2) < 0 then
            display alert "The number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string."
            error -128
        end if
        -- escape search string, and create back reference for each wildcard (the wildcard is a dot in sed) --> \\(.\\)
        set f to do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g;s/\\*/\\\\(.\\\\)/g' <<<" & quoted form of f
        -- escape the replacement string, Perl replace wildcard by two backslash and an incremented integer, to get  the back reference --> \\1 \\2
        return {f, (do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g' | /usr/bin/perl -pe '$n=1;s/\\*/\"\\\\\" . $n++/ge'<<<" & (quoted form of r))}
    end escapeForSED
    For what you want to do, you must have the wildcard in the same position in both string. --> find "Table 1::$*$3", replace "Table 1::$*$4"
    Important, you can use no wildcard in both (the search string and the replacement string) or you can use any wildcard in the search string with no wildcard in the replacement string).
    But, the number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string.

  • Help changing permissions using a shell script

    Hey,
    Here's the situation. We have 18 Macs, they're all cloned from a master image and have 2 local accounts - Administrator and Student.
    There are some files on the machines that the student account does not have permission to access, but it's critical that they do. I've written a shell script to change the files so that everyone has permission to read, write and execute them:
    #! /bin/bash
    clear
    sudo chmod ugo+rwx /Library/Audio/Plug-ins/Components/FM8.component
    sudo chmod ugo+rwx /Library/Audio/Plug-ins/VST/FM8.vst
    sudo chmod ugo+rwx /Library/Audio/Plug-ins/VST/FM8\ FX.vst
    sudo chmod ugo+rwx /Library/Application\ Support/Digidesign/Plug-ins/FM8.dpm
    In theory, this means I can just run the script, type the admin password in once and its done (as opposed to typing in the password 4 times and navigating to each file individually.)
    However, this doesn't quite work as planned.
    If I run the script, navigate to the files using the Finder and 'get info' it declares that "Everyone" can "Read & Write". The student account can see the file properly, but the finder just thinks there's nothing there (Size=Zero KB.) Only when I explicitly add the Student account (Add->Student) and set it to "Read & Write" does it start working.
    2 questions really - Why does it do this, and how do I make it work?
    It was my understanding that if everyone could read, write and execute there wouldn't be a problem, regardless of which account tries to access the file?
    Also, if there is a better/easier/faster way of doing the same thing I'm open to suggestions.
    Thanks.

    Thanks Tony,
    Your reply was helpful, I didn't realise you could tie all the paths together and just use one chmod command.
    I actually solved the issues myself this morning (fresh head on after a good nights sleep!)
    It turns out the 'files' I'm trying to modify aren't strictly files at all, they're packages. Using just chmod changes permissions for the top of the package only (hence why I could see the files but they said Zero KB.)
    adding -R to the chmod modified permissions to everything inside the package as well, which has resolved the issue.
    Thanks for the help though!

  • Running report in concurrent manager using unix shell script to create PDF

    Hi,
    I need help urgently, we are in the process of migrating from 10.7 to 11i. My problem is we have a report created in 10.7 that is ran through concurrent manager using shell scripts(host) and the output is stored as .pdf, in 10.7, it works perfectly. Now I am also doing it in 11i but it gives some error. The shell script from 10.7 is: r25runm module=$XXX_TOP/srw/test.rdf \
    userid=$1 batch=yes \
    desformat=pdf destype=file \
    desname=$XXX_TOP/outbound/test.pdf
    I change the shell script in 11i as follows:
    ar60runb report=$XXX_TOP/reports/US/test.rdf \
    userid=$1 batch=yes \
    desformat=pdf destype=file \
    desname=$XXX_TOP/outbound/test.pdf
    I checked your metalink, and I am confused which is the right executable I should use, is it ar60runb or ar60run or rwrun60b or rwrun60c or rwrun60b, which is which? how many parameters do I have to include?, some documents are saying I have to use the 4 parameters-orauser/pwd, userid,username, request_id, others one.Which parameter/s go/es with what executable. We are using HP-UX server 64 bit. In 11i, when I run in concurrent manager it gives me an error:The executable file /chdev/fd11/u00/fd11appl/xxx/1.0/bin/test for this concurrent program cannot be executed.
    Contact your system administrator or support representative. Verify that the execution path to the executable file is co.
    I have checked Metalink and follow the directions, created a link fndcpesr, check and set the permissions, etc. Play around with the executables ar60runb or rwrun60 etc., the parameters. The ar60* or rwrun60* executable permissions are -rwxr-xr-x and $XXX_TOP/fnd/../fndcpesr is -rwxr-xr-x. Also, why is ar60* executables located in $FND_TOP/bin, whereas rwrun60* executables are in $ORACLE_HOME/bin? Please help, I need an answer urgently ,I have to complete this task before Tuesday 9/16/2003 for our migration deadline. Thank you very much.

    I have already fixed the problem, TY anyway

  • Generate RMAN backup Script using unix shell script

    Hello,
    Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
    e.g.
    rman.conf
    CHANNELS=4
    USE_CATALOG=Y
    DEVICE='sbt_tabe'
    etc.,
    many thanks,
    kam

    You can actually encapsulate the RMAN commands inside the shell script.
    However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
    Thus, for example,
    echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
    echo "backup database plus archivelog" >> RMAN_Script.rmn
    echo "backup archivelog all" >> RMAN_Script.rmn
    creates RMAN_Script.rmn with 3 commands.

  • IIS Issue:when trying to download code from AWS S3 and deploy in IIS server using Power Shell script while Windows startup Default Application pool is not started.

    Hi,
    I am trying to launch Amazon EC2 windows server 2008 R2 instance using AWS Auto Scaling feature. I have used cusmized AMI in Autoscaling Launch configuration to launch an instance.I have placed Power Shell script in AMI. 
    The responsibility of script is to download code from AWS S3 and deploy in IIS server while windows startup first time.
    When i check status, IIS is started succesfully. But default Application pool is not started.
    To resolve this issue i have written one scheduled script. It helps to start the application pool if any application pool is in stopped state.
    After this Application pool is started but i am not able to communicate with IIS server through browser.  
    Please help any one to resolve this issue.
    Thanks in advance

    Hi Vchreddy,
    For the IIS issue, we recommend you can post in IIS forum for more effective support:
    http://forums.iis.net/
    Thanks for your understanding.

  • Trouble using Run Shell Script with python in Automator

    Hi. I have a python script I want to run in Automator (update_puzzles.py). All it does is check, rearrange and update files and there is not supposed to be any input. I can get the script to run outside of Automator, in Terminal, by navigating to the right directory and typing "python update_puzzles.py"
    I must not be setting up Run Shell Script correctly. I have it set to /bin/bash and Pass Input to stdin. The command line simply reads python /pathname/update_puzzles.py (where pathname is the path to the .py file, which I got by dragging the file onto the Run Shell Script command window). There are no actions before this in my workflow and the action after is View Results.
    The log says Run Shell Script failed, and the error is "Traceback (most recent call last):"
    Any suggestions?
    Thanks so much.

    If the script is expecting to do stuff with files in the same directory as the executable, you will probably need to add a statement to change to the appropriate working directory. The shell used in the Automator *Run Shell Script* action is a generic one that does not share any of the environment variables that the Terminal uses.

  • What to use in shell script for CR when \n doesn't work.

    Hi I'm new to LINUX and I'm writing a shell script.
    I noticed when I'm at the command line I can type:
    echo "one\ntwo"
    and it will produce:
    one
    two
    when I put that SAME line in a shell script I get:
    onentwo
    Why? What can I use as CR character in a UNIX shell script that will work?

    That's not a normal behavior, not in Bash. Are you using the c-shell csh/tcsh ? or perhaps you have echo defined as an environment variable that was not exported, so it only works in your current shell, but not in any subshell. If you use the c-shell you may sooner or later run into problems, since this shell is not sh or bash complient.
    To enable the interpretation of backslash escape sequences in the korn or bourne shell you can use the -e paramter. For instance
    [dude@vm210 ~]$ echo -e "one\ntwo"
    one
    two

  • Use SHIFT key to get lower case while Caps Lock?

    hey all,
    so at work we finally switched from dells to g5s, but now some of the things i got used to in windoze i'm missing in osx!
    in windows you could caps lock but if you occasionally intermittently needed lowercase, you could hit shift while typing and get the lower case. won't do it in osx. anyone know of a workaround?
    thanks!

    AFAIK, there is none other than to disable the Caps Lock.
    There are many differences between Mac OS X and Windows. Best to educate yourself on them. See my "Learning About Mac OS X" FAQ.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X
    Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • How to excute a power shell script to remote machine using power shell script folder path and script name

    Hi,
    Let say, I have 3 parameters.
    1. Script FolderPath (Remote path for e.g \\RD101\ScriptSharedFolder     Here RD101 is one server)
    2. Script Name(StopAllService.ps1)
    3. Server Name (RD45)
    I want to execute a powershell scritp in my local machine(Test1)  and in that script I want to pass the above three parameters.Now I want to excute the StopAllService.ps1 script into RD45 server. But the script is available in RD101 machine.
    So What I want to here How can we do this ? I have script name and script folder path and target execution server name.
    Pls giude me or give me the script.
    By
    A Path Finder..
    JoSwa 
    If a post answers your question, please click &quot;Mark As Answer&quot; on that post and &quot;Mark as Helpful&quot;
    Best Online Journal

    Hi,
    You got 2 solutions for your problem:
    1- If you have permission to run scripts in the remote computer without specifying your credential,
    then, the first reply solve your problem.
    2- If you have permission to run scripts in the remote computer
    having to specify your credential, l then,
    my solution solves your problem.
    If the remote computer requires signed scripts only, you need signed script. Period. Or are you trying to break remote computer security?
    If you need signed script, there's no psdrive that'll circumvent such requirement.
    The problem is that the execution policy is set to "RemoteSigned". Using the URL explicitly tags that script as being from a remote source, and the policy blocks it.  The PSDrive provides a local reference for the script.  It does not
    sign the script but the local drive reference may prevent it from being blocked for being from a remote source. I'll test that later.
    Script signing is not and should never be considered a security measure. It is easily circumvented by running the script using powershell.exe, and using the -ExecutionPolicy parameter to override whatever the local execution policy setting is. 
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Help on using Textutil shell script

    I remember a very helpful page on the Apple site describing the use of textutil and all its parameters. Now I want to use it again (to rename files), but the help pages seem to have disappeared. I've searched the Apple site and googled all sorts of combinations, but can't find what I'm looking for.
    Can anyone point me to an idiot's guide? It was an amazing tool for concatenating Word docs, and I look forward to using it again....

    Yes, that looks like it - thanks! It's bookmarked now. I thought there were more examples... I also thought I could use textutil to rename files (via Filemaker, using Filemaker to calculate the new file name based on the old one, don't even ask!! - there's only 19000 of them).
    Bit more research called for, but thanks for the link.

  • Copy .vhd from secondary storage account to another storage account in primary location (RA-GRS) enabled using power shell scripts

    All,
    Hope you are doing great. I have a storage account which is RA-GRS enabled. Which has couple of (IaaS based vms) .vhd. I have taken few snapshots on the VMs too.
    Queries:
    1. How do I copy the .vhds from secondary storage account to different account in primary location?
    2. If I copy the .vhds. Does it copy all the snapshots which was taken?
    Please advice. Many thanks!
    Regards,
    Swamy

    Hi Jambor,
    Hope you are doing great. I am facing a problem.
    1. Imagine I have a storage account with RA-GRS enabled. US East (Primary) and US West (Secondary)
    2. I have created a VM in US East and taken couple of snapshots. Which means the .vhd and its snapshot will be replicated in the Secondary location.
    3. Assume that Primary site is down. Not I want to read the .vhd and its snapshot from secondary and create VM in Primary location.
    4. I tried the below code but it is throwing exception 404 Not found.
    Please advice.
    Regards,
    Swamy
    $client.LocationMode
    =0
    $createdBlob=$client.GetBlobReferenceFromServer($theDestBlobUrl)
    Write-Output$createdBlob.SnapshotQualifiedStorageUri.PrimaryUri.AbsoluteUri
    try
    $createdBlob.BreakLease()
    catch{}
    $blobUri125=New-ObjectSystem.Uri($theUrl)
    $client.LocationMode
    =0
    $createdBlob.StartCopyFromBlob($blobUri125.AbsoluteUri)
    $blobReference=$client.GetBlobReferenceFromServer($theUrl)

Maybe you are looking for

  • Requiring a digital signature prior to hitting "Submit By E-mail"

    How do I make it a requirement to digitally sign a form when selecting the "Submit By E-Mail"?

  • "Track this list in Access" not working

    I have a PC with Microsoft Office *2003*, Access 2003, and Windows XP. We use SharePoint 2010. With this configuration, I am able to create a linked table in Access. I have a laptop with Microsoft Office *2010*, Access 2003, and Windows XP. When I us

  • Horizontal scrolling tekst

    I am a new user of fcp. i was using Pinnacle studio (windows) before. often i prefer usinf horizontally scrolling tekst to explain places, locations etc. i cannot find this tool in fcp. any sugestions? thanks! Rogier

  • Trying to update my account with new email address.

    My original account details I put in the wrong (non existent) email address. Problem is appears I have since already setup a new account with new email address from my iphone.  Now verification emails are being sent to non existnet email address and

  • Select options values pass to function module

    Hi all,         I want to pass the values entered in the select options to the function module. How should my function module interface be declared for passing the select options I tried declaring like t_range type data in the tables tab.  But this t