Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:30:45+00:00 2026-05-29T23:30:45+00:00

I have a simple question. I know that shell scripts are slow/ineffective when it

  • 0

I have a simple question. I know that shell scripts are slow/ineffective when it comes to recursion and looping.

Generally, is it possible to read the input continuously instead of having to loop the read/”grab” part of the code, for instances when the input is continual and in plenty( a kind of EVENT DRIVEN scenario ).

For example,,
I use fedora16(gnome3.2) and for reasons unknown the capslock notification is missing. I own a netbook and don’t have the “luxury” of indicator leds. So I’ve decided to write a shell script to notify me when the capslock key is pressed. I figured out a way to know the key state.

xset -q | grep Caps | awk '{print $4}'

that would give me “on”/”off” as the output. I can like have the loop to execute every one second(or less) but that would be a very crude way of doing it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:30:47+00:00Added an answer on May 29, 2026 at 11:30 pm

    What you wrote is event-driven. xset -q produces some output, which only at that point (i.e. when it’s produced) is consumed by grep. At that point, grep might produce some output (only if it matches Caps) and only in that case will awk process something.

    The problem here is not bash – the “problem” is xset -q. It was not designed to continuously give you output. It was designed as a one-shot output command.

    To touch the other part of the question – if you actually just need an indicator, look here:

    • https://askubuntu.com/questions/30334/what-application-indicators-are-available/37998#37998

    An excellent source of all sorts of indicators. One of them is Keylock indicator (search the above page to see more info):

    Keylock indicator

    The above link is from askubuntu.com, i.e. it’s Ubuntu-centric, but the above seems to be available for Fedora, too:

    • http://forums.fedoraforum.org/showthread.php?t=257835

    From the above thread (this post by fewt):

    su -
    yum install lock-keys-applet
    exit
    killall -HUP gnome-panel
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just have one simple question about XSS attack. I know that you can
I have a simple question. I know that I can prevent a form to
i just have a simple question to ask. For XML file, i know that
I have what I know is a simple question, but after many searches in
I know this is a simple question for someone out there, but I have
I have a simple question, but I'm about 80% sure that the answer to
I have a simple question that I am posing mostly for my curiousity. What
I have a simple question: Would you rather use a plugin that is actively
I have some simple shell scripting tasks that I want to do For example:
This is probably a simple question that I am just missing but I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.