2

I am running Linux Mint 20. Cinnamon edition.

I installed osdclock. When I run osd_clock it displays it in the left bottom corner.

If I run osd_clock -t it runs on the top left corner.

I can run it at all 4 corner. I can also offset it using -o, but it only moves it at the vertical line. I can not seem to move it along the horizontal line...

But, is there any way to run it in the center of the screen?

Here is the man page https://manpages.debian.org/testing/osdclock/osd_clock.1.en.html

Anyone familiar with that program?

Cheers.

I.P
  • 111
  • 1
  • 8
  • As you've already been told, the app doesn't do that. You might look to conky as an option. It can display a clock, among other things, and be positioned anywhere you want to. – KGIII Nov 25 '20 at 18:28

2 Answers2

0

You linked the manual for osdclock in your Question, and it says "No". The program is ancient. I don't think your feature is on the "will-be-implemented-soon" list.

So there is your answer. ... but having said that... :

There might be a workaround, where you specify leading spaces to the -F format parameter in order to "left-pad" with spaces. That only works in an optically pleasing way only if your Desktop background has the same color at least for the left half of the screen for the portion of height, where you plan to display the clock.

EDIT: After playing around -F parameters, OP @IP found, that "Spaces" don't work, but that there is a way to tell strftime to pad using ".%_100c".

  • Cheers, that does work rather well. (Sorry, can not yet upvote). However, I am not sure how to make an "empty space" in this format. Perhaps someone knows? I used ____________ %c%________________ to center, which does work fairly ok, so long as I am on the bottom of the screen. If I wanted real center though... that would look ugly. Cheers. – I.P Nov 25 '20 at 18:39
  • @I.P Did you quote your spaces? Like so -F " LotsOfSpaces %c" ? – Alex Stragies Nov 25 '20 at 18:42
  • 1
    that does sadly not work. (Spaces goes all bad for it.) However, ".%_100c" does (in case anyone should be interested). I was not able to get rid of the . at the start, as the _100 shift is otherwise not registered. Interestingly, for %a it does work... oh well. Anyway. I am happy with it :) Cheers and have a nice day. – I.P Nov 25 '20 at 18:53
  • I'm glad i could help :) For the leading ".": You could try replacing it with one of the Zero-Length unicode characters. Or the really slim vertical line on the left side of the character "box" – Alex Stragies Nov 25 '20 at 19:03
0

You can use xdotool.

osd_clock has name XOSD so something like:

xdotool search --name "XOSD" windowmove X Y

where X and Y are coordinates.

If you want you can check size of window by getwindowgeometry as well as size of monitor(s) by xrandr --listmonitors.


If you have one or equal sized + same orientation monitors you could perhaps do something like this:

#! /bin/sh -

win_name=$1 x=${2:-0} y=${3:-0}

eval "$(xdotool search --onlyvisible --limit 1 --all --name "$win_name" getwindowgeometry --shell)" wmctrl -d |
awk
-v x="$x"
-v y="$y"
-v win_w="$WIDTH"
-v win_h="$HEIGHT"
-F "[ x]" ' $2 == "" { x += $4 / 2 - win_w / 2 y += $5 / 2 - win_h / 2 print x, y } ' | xargs xdotool windowmove "$WINDOW"

Use as ./script <WINDOW-NAME> x y where in this case <WINDOW-NAME> would be XOSD and x / y are optional fine tuning arguments.

With different sized monitors and perhaps tilted ones etc. one could still script it - (have one of those as well) - but more work, and perhaps not worth it.

ibuprofen
  • 2,890