Clock app that shows time when a keyboard shortcut is used

Please post all general support questions for LXDE here.
Locked
bieniekmat
Posts: 4
Joined: Sun Aug 10, 2014 1:54 pm

Clock app that shows time when a keyboard shortcut is used

Post by bieniekmat »

Hey,

My panels are minimized which is why I would rather use a keyboard shortcut to display the time on the screen, ideally the time would be presented for a couple of seconds and then disappear. The app can run from the command line which would mean that I would have to create a keyboard shortcut myself.

Anyone heard about something like that? Any alternatives? I could not find anything, many thanks.
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: Clock app that shows time when a keyboard shortcut is us

Post by seppalta »

Install dclock and then add a keybind in ~/.config/openbox/rc.xml like the following:

Code: Select all

<keybind key="W-o">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>time</name>
        </startupnotify>
        <command>dclock -date "%A %x"</command>
      </action>
    </keybind>
I used the key combo "super+o", since it was one of the few that I still had available and o=oclock :D . You could, of course, use anything not already used and works. You can even use dclock to set-off a pleasant alarm.
drooly
Posts: 791
Joined: Mon Apr 08, 2013 6:45 am

Re: Clock app that shows time when a keyboard shortcut is us

Post by drooly »

Code: Select all

snip
<command>urxvt -fn -*-terminus-bold-r-*-*-32-*-*-*-*-*-*-* -g 5x2+200+200 -e sh -c 'date "+%R" ; sleep 3'</command>
snip
bieniekmat
Posts: 4
Joined: Sun Aug 10, 2014 1:54 pm

Re: Clock app that shows time when a keyboard shortcut is us

Post by bieniekmat »

Thanks seppalta and drooly,

On my main fedora system I could not find dclock in the repository, but I run into xclock which works ok. However, on my laptop, on arch it was easy to add dclock so I use it on the laptop.

I would like to display only for a fraction of a second, and then kill it. However, I cannot seem to be able to do this with openbox and xbindkeys.

The closes I came was with xbindkeys, the following creates the test files as expected
`dclock -date '%A %x' &` && sleep 0.5 && touch ~/test

However, the final version does not work
`dclock -date '%A %x' &` && sleep 0.5 && kill `pidof dclock`


I might tinker with it later a bit.
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: Clock app that shows time when a keyboard shortcut is us

Post by seppalta »

Code: Select all

<keybind key="F8">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>time</name>
        </startupnotify>
        <command>dclock -date "%A %x"</command>
      </action>
    </keybind>
    <keybind key="F9">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>kill time</name>
        </startupnotify>
        <command>killall dclock</command>
      </action>
    </keybind>
Click "F8" to launch dclock, "F9" to remove. That would be about a half second. Be careful to bind two keys not already bound and not used in regular typing.
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: Clock app that shows time when a keyboard shortcut is us

Post by seppalta »

Or, make up 3 shell scripts as follows:

Code: Select all

  dclock1.sh
#!/bin/bash
dclock -date "%A %x" &
exit

Code: Select all

  dclock2.sh
#!/bin/bash
killall dclock &
exit

Code: Select all

  dclock3.sh
#!/bin/bash
~/bin/dclock.sh &&
sleep 1 &&
~/bin/dclock1.sh &&
exit
Put them in ~/bin/, and use for command in your keybinding ~/bin/dclock3.sh. You can probabily replace "killall" with "pkill" if more convenient.
drooly
Posts: 791
Joined: Mon Apr 08, 2013 6:45 am

Re: Clock app that shows time when a keyboard shortcut is us

Post by drooly »

Code: Select all

snip
<command>urxvt -g 5x2+200+200 -e sh -c 'date "+%R" ; read -n1'</command>
snip
this will display the clock until you hit a key.
i removed the x-font to make the command more generic; i guess you could use it with almost any terminal now.
you can even remove the blinking cursor, at least with urxvt, reducing the output to 1 line.
Locked