Coder Social home page Coder Social logo

stuartlangridge / gnome-shell-clock-override Goto Github PK

View Code? Open in Web Editor NEW
89.0 8.0 33.0 214 KB

Override the Gnome Shell clock with a new time format or text of your choice. Works with new versions of Shell such as 3.18

License: MIT License

JavaScript 95.35% Makefile 4.09% Shell 0.56%

gnome-shell-clock-override's Introduction

gnome-shell-clock-override

Override the Gnome Shell clock with a new time format or text of your choice. Works with new versions of Shell such as 3.18.

Get GNOME Extension

Gnome Shell doesn't permit many changes to the format of its clock; in particular, it's not possible to remove it completely or to add text around it. That's what this extension is for: you can set the clock's "format string" to change how the Gnome Shell clock is displayed (do you want it as HH:MM? HH.MM? "10:37:21 am"?), including setting it to just a fixed string (for example, a bell) so you have somewhere to click to see notifications and calendar but no clock on-screen.

Extension screenshot

For techies, we use the GLib GDateTime codes to specify actual times in your clock string, with three additions:

  • %;cf, a little emoji Unicode clock face (thanks to dsboger for that!)
  • %;vf, quarters as vulgar fractions
  • %;@, internet time (.beat)
  • %n, line breaks

Note that we still try to honour Gnome Shell's clock settings. So if you expect your clock to show seconds (or to update once a second, rather than once a minute) then you'll need to have turned on "show seconds" in Gnome Tweak Tool (under Top Bar) (or the terminal way).

Building from GitHub

The make definition file knows all you need to build, distribute, and install (for the current user) the extension.

make -j [build|clean|dist|distclean|install|test]

Dependencies:

  • gettext
  • GNU Make
  • glib-compile-schemas
  • gnome-shell 3.18 or newer
  • gnome-shell-extension-tool
  • ZIP

Development Dependencies:

  • jasmine-gjs

Translations wanted

Please help us translate Clock Override to more languages. You can find translations in the locale directory. You can help by adding any missing strings (lines with msgstr "") in your language, or by adding a new language.

gnome-shell-clock-override's People

Contributors

brandl-muc avatar da2x avatar dsboger avatar hlechner avatar jonnius avatar kariiboo avatar nyaran avatar stuartlangridge avatar thechriswalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gnome-shell-clock-override's Issues

Not working correctly on a vertical panel

When using the extension "dash to panel" setting the "Panel screen position" to "left" or "right" to have a vertical panel, the symbols %n to jump a line or %F to draw the ISO date are not working.

All the symbols seem to be ignored, besides a single %S to show the seconds.

I would like to be able to use "%H:%M:%S%n%F" and that they are shown center-aligned on a vertical panel.

Week number not working

according to http://strftime.org when I use %U or %W the week number should be printed but instead some of the currently present output is removed. For example:
before: "%F %H:%M" -> 2018-05-04 16:35
after: "%F %W %H:%M" -> pią 16:35

Ubuntu 18.04

Format string only working if it contains %;

I'm on Ubuntu 18.04 and I installed clock override both from extensions.gnome.org and the Ubuntu software store.
With both sources I encounter the same issue. The format string is not interpreted correctly with some exceptions:

  • Example %H.%M yields %H.%M
  • Example 🔔 works
  • Example %;cf (emjoi clock face) works
  • Example %H %;vf (slow time) works
  • Example %FT%T (iso date time) yields %FT%T
  • Example %H:%M @%;@. (local and internet time) works
  • Example It is %M minutes past hour %H fails
  • %% yields %% instead of %
  • %F (%a) %;cf %T works
  • %F (%a) %;cf %T fails
  • %F (%a) %; %T yields the default (same as w/o Clock Override)

So a format string only seems to work if it contains %;* where * denotes something valid as cf or vf. A format string is ignored if it contains any other combination of %;, even if added to a format string that works. All other strings seem to fail, i.e., not interpret the format string.

Bell icon not displaying anymore

Hi,

I was having fun :) with this good extension, and I really liked the bell icon, but for some reason, I'm not able to see that icon any more :(

In my taskbar, I see blank, like this:
image

And, when I open the settings, it's now like this:
image

And this happens while I was able to see the bell icon before.

Thank you in advance.

Displays formatting code rather than clock

Since the last update from gnome shell extensions website this extension now shows my formatting code where the clock should be e.g. "%r" is displayed rather than the appropriate time formatted. Ubuntu 18.04 Gnome Shell 3.28.2

[QUESTION] (low priority!) Comma-separated seconds-since-epoch

Hello!

Thank you for writing this extension, it's great!

On my Mac I use the BitBar app to display the comma separated epoch beside my date/time display. I'd like to do something similar in Gnome and was wondering if I could use this extension to accomplish that.
Essentially I want to display this:
{ 1,564,058,167 }

Which I would do in a script:
EPOCH=$(/bin/date +%s | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')
echo "{" "${EPOCH}" "}"

Do you know of a way to include the output of a script in the text set by your extension? Or, is there a way to comma separate the %s value in your extension?

Don't worry if this can't be done, I know this is a long shot. Please close this once answered, thank you.

Deprecated call of object.actor

At the current version of it under Fedora 34 the following warning is logged:

Usage of object.actor is deprecated for DateMenuButton
get@resource:///org/gnome/shell/ui/environment.js:316:29
enable@/home/XXX/.local/share/gnome-shell/extensions/[email protected]/extension.js:39:5
_callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:167:32
_enableAllExtensions/<@resource:///org/gnome/shell/ui/extensionSystem.js:599:22
_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:598:37
_sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:626:18
_emit@resource:///org/gnome/gjs/modules/core/_signals.js:133:47
_sync@resource:///org/gnome/shell/ui/sessionMode.js:195:14
popMode@resource:///org/gnome/shell/ui/sessionMode.js:163:14
_continueDeactivate@resource:///org/gnome/shell/ui/screenShield.js:510:30
deactivate/<@resource:///org/gnome/shell/ui/screenShield.js:501:44
finish@resource:///org/gnome/shell/gdm/authPrompt.js:528:13
finish@resource:///org/gnome/shell/ui/unlockDialog.js:870:26
deactivate@resource:///org/gnome/shell/ui/screenShield.js:501:26
ScreenShield/</<@resource:///org/gnome/shell/ui/screenShield.js:109:57
_emit@resource:///org/gnome/gjs/modules/core/_signals.js:133:47
_convertToNativeSignal@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:169:19

Option to show the output of a (bash) command?

Hi, thanks a lot for this useful extension. I'd like to show two time zones that I'm currently doing with argos in a separate widget using the date command, but would love to rather replace the default clock indicator. Any chance to do this with this extension?

something went wrong error message in Fedora 34

TypeError: Gtk.EventBox is not a constructor

Stack trace:
_init/<@/home/jaap/.local/share/gnome-shell/extensions/[email protected]/prefs.js:96:22
_init@/home/jaap/.local/share/gnome-shell/extensions/[email protected]/prefs.js:86:11
wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
buildPrefsWidget@/home/jaap/.local/share/gnome-shell/extensions/[email protected]/prefs.js:138:19
_init@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:209:40
OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:122:28
asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:177:20
main@resource:///org/gnome/Shell/Extensions/js/main.js:19:13
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
start@resource:///org/gnome/gjs/modules/script/package.js:190:8
@/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

No longer working in Gnome 45

The settings of extension [email protected] had an error:

SyntaxError: export declarations may only appear at top level of a module

Stack trace:

@file:///home/peter/.local/share/gnome-shell/extensions/[email protected]/prefs.js:4:16
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

"make install" not working anymore

When trying to install my current source with make -j install as by README.md I get the following error:

gnome-shell-extension-tool --reload-extension="[email protected]"
Reloading extensions does not work correctly and is no longer supported

Actually, the problem seems rooted more deeply:

% gnome-shell-extension-tool -e extension.js
gnome-shell-extension-tool is deprecated, use gnome-extensions instead

This happens on Ubuntu 20.04.1 LTS, version of package gnome-shell is 3.36.4

% apt-cache policy gnome-shell
gnome-shell:
  Installed: 3.36.4-1ubuntu1~20.04.2

Sadly I'm not really able to solve this myself. But it seems that the makefile should use the mentioned gnome-extensions to create and install the extension. See help pages:

% gnome-extensions create --help
gnome-extensions: Unknown option --help

Usage:
  gnome-extensions create [OPTION…]

Create a new extension

Options:
  --uuid=UUID                   The unique identifier of the new extension
  --name=NAME                   The user-visible name of the new extension
  --description=DESCRIPTION     A short description of what the extension does
  -i, --interactive             Enter extension information interactively

and

 gnome-extensions install --help
 gnome-extensions: Unknown option --help
 
 Usage:
   gnome-extensions install [OPTION…] EXTENSION_BUNDLE
 
 Install an extension bundle
 
 Options:
   -f, --force             Overwrite an existing extension

Latest update (v7 for Gnome 3.28) stopped working

I installed the latest update (version 7) on Ubuntu 18.04 with Gnome Shell 3.28.2 and it broke the extension. It doesn't matter what string combination I use, none show anymore, only the patter shows rather than the time/date. Also, yes, I did restart gnome-shell after updating.
Here's a screenshot of the topbar showing the output of some code that used to work until the new version was updated:
selection_005

I've had to manually install version 3 which it's supposed to be for Gnome 3.18 and that works on my system.
Let me know if there's anything I can do to help debug this.

Quick status update

The extension doesn’t currently support GNOME 40.

I’ve not accepted pull requests to fix support. I’ve been busy, and haven’t had the time to provide proper feedback to contributors. I’m sorry about not providing better feedback. I also didn’t have a working GPU for a while and it took time to source a replacement.

Current roadblock: The extension causes performance issues in GNOME 40 like UI stuttering with the app grid and small hangs when the clock updates. I’m not sure what’s causing the problem. The extension also randomly stops updating the time, and I haven’t had the time to investigate that.

I won’t enable installation on GNOME 40 through the GNOME Extensions portal until these issues are resolved. I hope to have time to work on these issues in about a month’s time. Sorry about the delays.

Provide placeholder for the original clock label

Would it be possible to provide a placeholder to instert the original clock label, so that the user can keep and expand it (e.g. with the analog clock)? I know it is possible for the user to build the original string himself, too.

Help-link in Settings leads to incorrect page

In the Settings, there is a link, "What do all these %x codes mean?"

This leads to a Github document page with an anchor g-date-time-format.

Unfortunately, it looks like the intended link no longer exists, as there is no such anchor or documentation on the target page. I have tried to find out where it should lead, but I have failed!

I believe that some of the % codes are the same as described in the Linux command date, but not all. E.g., %;cf, %;@ and others.

Please would you update the link?

[REQUEST] Multiline

Woud it be possible to display hour and date in two lines? Like windows 7

clock

Clock face rounding and vulgar fraction rounding do not coincide

For the minute range :00 to :29 the Unicode symbols CLOCK FACE XXX OCLOCK is used (e.g. 🕒), for the range :30 to :59 CLOCK FACE XXX-THIRTY is used (e.g. 🕣). This means that the minutes are truncated (rounded down) to half hours.
The vulgar fractions on the other side are rounded to the nearest quarter hour.

This is unintuitive behavior and leads to results as "🕔 17 1/2" for times such as 17:28. Note that the vulgar fraction already shows "half past" but the Unicode clock face still represents "whole" hour.

I think the OCLOCK symbol should be used for the range :45 to :14 and the THIRTY symbol for the range :15 to :44.

[Request] Add unit tests

I'm not at all js savvy nor would I know how to achieve this, but I think it might by a good idea to add tests to the project to avoid that the plugin breaks like with #13 . The bare minimum seems to be to test overrider() in extension.js

Any ideas or comments on this?

Plugin broken after last update

The format string is not parsed correctly. It gets displayed in Gnome top panel instead of the parsed counterpart. Can give further detail if needed.

Fuzzy clock

Hey, I wanted a fuzzy clock in Gnome, but I couldn't find any documentation for extensions and I ended up just altering this extension to show a fuzzy clock.

If you don't know its just a clock rounded to the 5min mark, shown in full words not numbers. It looks like this:
Fuzzy clock

Here is my patch, it's not ready to be merged as it now ignores all preferences (if true then fuzzy), but here is the code. If you want to use it you'd have to add a preference and the UI, but I don't know how to do that.

diff --git a/extension.js b/extension.js
index d9b34a9..8b63426 100644
--- a/extension.js
+++ b/extension.js
@@ -7,6 +7,31 @@ const Convenience = Me.imports.convenience;
 
 var settings;
 
+var HOURS = [ "ONE",
+    "TWO",
+    "THREE",
+    "FOUR",
+    "FIVE",
+    "SIX",
+    "SEVEN",
+    "EIGHT",
+    "NINE",
+    "TEN",
+    "ELEVEN",
+    "TWELVE" ];
+var FUZZY_RULES = [ "%s O'CLOCK",
+    "FIVE past %s",
+    "TEN past %s",
+    "QUARTER past %s",
+    "TWENTY past %s",
+    "TWENTY FIVE past %s",
+    "HALF past %s",
+    "TWENTY FIVE to %s",
+    "TWENTY to %s",
+    "QUARTER to %s",
+    "TEN to %s",
+    "FIVE to %s" ];
+
 function init() {
     settings = Convenience.getSettings();
 }
@@ -51,31 +76,48 @@ function overrider(lbl) {
     var t = lbl.get_text();
     var FORMAT = settings.get_string("override-string");
     var desired = FORMAT;
-    if (FORMAT.indexOf("%") > -1) {
-        var now = GLib.DateTime.new_now_local();
-        if (FORMAT.indexOf("%f") > -1) {
-            var hour = now.get_hour();
-            // convert from 0-23 to 1-12
-            if (hour > 12) {
-                hour -= 12;
-            }
-            if (hour == 0) {
-                hour = 12;
-            }
-            var clockFaceCodePoint = 0x1f550 + (hour - 1);
-            var minute = now.get_minute();
-            if (minute >= 30) {
-                clockFaceCodePoint += 12;
-            }
-            var repl;
-            if (String.fromCodePoint) {
-                repl = String.fromCodePoint(clockFaceCodePoint)
-            } else {
-                repl = fromCodePoint(clockFaceCodePoint);
+    var now = GLib.DateTime.new_now_local();
+    if (true) {
+        var hour = now.get_hour();
+        if (hour > 12) {
+            hour -= 12;
+        }
+        hour -= 1;
+
+        var minute = now.get_minute();
+        minute = Math.floor((minute + 2) / 5);
+
+        if (minute > 6) {
+            hour += 1;
+        }
+
+        desired = FUZZY_RULES[minute].format(HOURS[hour]);
+    } else {
+        if (FORMAT.indexOf("%") > -1) {
+            if (FORMAT.indexOf("%f") > -1) {
+                var hour = now.get_hour();
+                // convert from 0-23 to 1-12
+                if (hour > 12) {
+                    hour -= 12;
+                }
+                if (hour == 0) {
+                    hour = 12;
+                }
+                var clockFaceCodePoint = 0x1f550 + (hour - 1);
+                var minute = now.get_minute();
+                if (minute >= 30) {
+                    clockFaceCodePoint += 12;
+                }
+                var repl;
+                if (String.fromCodePoint) {
+                    repl = String.fromCodePoint(clockFaceCodePoint)
+                } else {
+                    repl = fromCodePoint(clockFaceCodePoint);
+                }
+                desired = desired.replace("%f", repl);
             }
-            desired = desired.replace("%f", repl);
+            desired = now.format(desired);
         }
-        desired = now.format(desired);
     }
     if (t != desired) {
         last = t;
diff --git a/metadata.json b/metadata.json
index f838e7f..f5e35f1 100644
--- a/metadata.json
+++ b/metadata.json
@@ -3,7 +3,8 @@
   "description": "Change what the clock displays",
   "shell-version": [
     "3.16",
-    "3.18"
+    "3.18",
+    "3.24"
   ],
   "settings-schema": "org.gnome.shell.extensions.clock-override",
   "url": "https://github.com/stuartlangridge/gnome-shell-clock-override",

does not work in GNOME 41.3

Absolutely loved this extension before I went to manjaro with GNOME 41.3. Looks like the development is kinda dead here?

The settings of extension [email protected] had an error:

TypeError: Gtk.EventBox is not a constructor

Stack trace:

_init/<@/home/ducky/.local/share/gnome-shell/extensions/[email protected]/prefs.js:96:22
_init@/home/ducky/.local/share/gnome-shell/extensions/[email protected]/prefs.js:86:11
wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
buildPrefsWidget@/home/ducky/.local/share/gnome-shell/extensions/[email protected]/prefs.js:138:19
_init@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:219:40
OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:128:33
asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:177:20
main@resource:///org/gnome/Shell/Extensions/js/main.js:19:13
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
start@resource:///org/gnome/gjs/modules/script/package.js:190:8
@/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

Error on Gnome 40.4.0

The settings of extension [email protected] had an error:

TypeError: Gtk.EventBox is not a constructor

Stack trace:

_init/<@/home/awx/.local/share/gnome-shell/extensions/[email protected]/prefs.js:96:22
_init@/home/awx/.local/share/gnome-shell/extensions/[email protected]/prefs.js:86:11
wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
buildPrefsWidget@/home/awx/.local/share/gnome-shell/extensions/[email protected]/prefs.js:138:19
_init@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:209:40
OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:122:28
asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:177:20
main@resource:///org/gnome/Shell/Extensions/js/main.js:19:13
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
start@resource:///org/gnome/gjs/modules/script/package.js:190:8
@/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

Clock not working after latest update?

Hi there,

After the last update my clock's % characters are not being displayed. Sorry I don't know how to check the version that I have.

I am using a custom format as follows:

"%d/%m     %H:%M   "

I have include the quotes above to show spacing, but they are not part of the format string. This now renders on my screen as that, it is not converted to the current time.

I did find that by including the swatch time I was able to have it work, therefore until this is resolved my format string is as follows:

"%d/%m     %H:%M                          %;@"

Would appreciate any input.

Clock container sometimes have improper width after unlock

Occurs (but not always) in Ubuntu 19.04, 19.10 on Top bar and Dash to panel.

If clock text after override is longer than original one, then after unlock, text is displayed with ellipsis; if is shorter there is margin on the right side.

Example :

ellipsis

It seems like that happen when function overrider(lbl) from enable() is called earlier than desktop if fully repainted.

After refreshing (on mouse hover or wait minute or second depending on format) container width is set properly.

I have workaround it by adding 1000ms timeout, instead of calling overrider(lbl) immediately :

GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {overrider(lbl)});

but maybe there is a better way to do it, like force repaint/refresh of container - I know nearly nothing about Gjs/GTK+ programming.

Add ability to change locale

I want the ability to have my GNOME in one language and my clock in another. Is that possible for an extension to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.