LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Clock at the top-right corner "instead of" on the taskbar

Posted 09-10-2016 at 08:41 PM by the dsc
Updated 07-31-2020 at 01:48 PM by the dsc (new solution)
Tags eyecandy

I like an auto-hiding taskbar, but a downside to it is that the clock is always hidden. Not that it's tremendously hard to just move the mouse over it in order to raise the clock again, but at the same time, often there is wasted space near the upper-right corner, that could well be used for a clock.

The easiest way to do it is simply with the osd_clock program:

Quote:
osd_clock -t -o -10 -r -s 1 -c "#DCDCDC" -F "%a %d %b %y %I:%M __________________________________________" -f "-adobe-helvetica-bold-r-normal--11-80-100-100-p-60-iso8859-1" &
(Probably there is a less-idiot way of doing that, without all the spaces, replaced here by underscores, added to give room to the window management buttons)

The problem is that this uses those primitive, client-side, unaliased xorg fonts, which are rather ugly.

Something like that could also be easily emulated with "aosd_cat", but then some other problems start to pile up. It would require some compositioning, even then the unconfigurable background frame could stand out as something ugly, and last, but not least, it's not "untouchable", but it "blocks" the mouse from whatever is behind it, unlike osd_clock.

A way to avoid these issues is to have an additional tint2 bar running (with a second config file and process), configured to run just with a clock, at that position. It still requires compositioning to have nice transparency, though, but the end-result looks much nicer, at the same time it would be a "true clock", and not some higher-level approximation with some lag. It still "intercepts" the click from what's behind, but you can at least configure it for some use, or even "fake" the same clicks on the titlebar with xdotool and key configurations that are set to invoke the same action (eg.: right-click calls openbox root menu, then the right-click command would be "xdotool key super-space", if that's also set to call the root menu).

A (bad) sample tint2 config file for such purpose:

Code:
# Just a somewhat cleaned-up modified version from a normal-purpose tint2 config file, so there still may be some useless left-overs.

# Background definitions
# ID 1  ---------PANEL BACKGROUND
rounded = 0
border_width = 0
background_color = #2D2D2D 0
border_color = #2D2D2D 0

# ID 2  ---------TOOLTIP BACKGROUND
rounded = 0
border_width = 0
background_color = #000 60
border_color = #2D2D2D 0


# Panel
panel_items = C
panel_monitor = all
panel_position = top right horizontal
panel_size = 23% 18
panel_margin = 70 0
panel_padding = 0 3 0
panel_dock = 0
wm_menu = 1
panel_layer = top
panel_background_id = 1

# Panel Autohide
autohide = 0
autohide_show_timeout = 0.01
autohide_hide_timeout = 0.01
autohide_height = 0
strut_policy = none




font_shadow = 1

# Clock
 time1_format = %a %d %b %y  %I:%M
 time1_font = Bitstream Vera Sans Bold 8
 clock_font_color = #DCDCDC 255
 clock_padding = 5 4
clock_background_id = 1
clock_lclick_command = ~/.scripts/wallpaperchanger.sh random
 clock_rclick_command = xdotool key super+space
clock_tooltip = %Uth week of %Y

# Tooltips
tooltip = 1
tooltip_padding = 2 2
tooltip_show_timeout = 1.2
tooltip_hide_timeout = 0.9
tooltip_background_id = 2
tooltip_font = Bitstream Vera Sans 8
tooltip_font_color = #FFFFFF 255

# Mouse
wm_menu = 1





# End of config

Regarding composition managers, both unagi and xcompmgr are very lightweight, but unfortunatelly buggier than compton. Unagi doesn't handle well the auto-hiding tint2, and xcompmgr leaves the tip of the top-left corner of the screen somewhat un-updated.







If some lag is not a problem, and both compositioning and configuring an extra tint2 are too much of a hassle, it's still possible to have something like that with a wmctrl+xdotool trick, running on the background:

Quote:
while true; do wmctrl -r :ACTIVE: -N "$(awk -F' \\─\\─\\─\\─\\─\\─' '{print $1}' <<< $(xdotool getwindowfocus getwindowname)) ────── $(date +"%a %d %b %y %I:%M %p")"; sleep 5; done &
A few alternatives, alongside with the original script (not mine) are shown in this thread:

http://askubuntu.com/questions/63403...-windows-title


What it does instead is to change the title of the active window every five seconds, adding the clock to it. Inactive windows will remain with lagged clocks until re-focused for five seconds. The big advantage is that the clock will never cover the window-management buttons at the right corner (or whatever you have at the right corner, if you have an OSX-like setup).

One can also have, instead of this spacer, a very long chain of empty, space-like characters, maybe even space itself, so that the clock/date will be pushed to the right corner, mimicking a right-alignment. So the title itself is left-aligned or centered, and the clock, right-aligned. The "problem" is that there will be a "..." somewhere along the middle of the empty space, but it doesn't bother me. I only tested it on Openbox.



---------------------------------------------------


Lately I have been using xclock for that:

Code:
C_ALL=pt_BR.utf8 xclock -digital -face "URW Gothic L-9:bold" -strftime "   %k:%M      %A, %e de %B   " -update 5 -padding 1 -fg "#fcfcfc" -bg "#2d2d2d" &

For Brazilian Portuguese exceptionally, at the upper right of a 1280x1024 screen. It won't block the buttons of a miximized window in my config, but if the buttons of a floating window are placed behind it, they'll be blocked.

On Openbox' rc.xml, I have this:

Code:
   <application title="xclock" class="XClock" name="xclock">
      <decor>no</decor>
      <maximized>no</maximized>
      <skip_taskbar>yes</skip_taskbar>
      <desktop>all</desktop>
      <layer>above</layer>
      <position force="yes">
        <x>933</x>
        <y>0</y>
      </position>
    </application>
So it remains there, without decorations. And also this:

Code:
        <action name="Execute">
          <command>xdotool search --name xclock windowactivate</command>
        </action>
To "show desktop" functions on Openbox' rc.xml So the xclock won't disappear.
Posted in Uncategorized
Views 988 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 10:29 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration