Page 1 of 1
Clock app that shows time when a keyboard shortcut is used
Posted: Fri Aug 29, 2014 11:43 am
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.
Re: Clock app that shows time when a keyboard shortcut is us
Posted: Fri Aug 29, 2014 3:54 pm
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

. You could, of course, use anything not already used and works. You can even use dclock to set-off a pleasant alarm.
Re: Clock app that shows time when a keyboard shortcut is us
Posted: Fri Aug 29, 2014 7:05 pm
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
Re: Clock app that shows time when a keyboard shortcut is us
Posted: Sat Aug 30, 2014 10:58 am
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.
Re: Clock app that shows time when a keyboard shortcut is us
Posted: Sat Aug 30, 2014 7:12 pm
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.
Re: Clock app that shows time when a keyboard shortcut is us
Posted: Sat Aug 30, 2014 7:37 pm
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.
Re: Clock app that shows time when a keyboard shortcut is us
Posted: Sun Aug 31, 2014 8:17 pm
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.