How to integrate a Thunderbird extension with Lightning
Update 2022 - MailExtensions
There is a better way to do this with newer versions of Thunderbird.
First of all, you need to create the basic Thunderbird extension layout. This is the same layout as in modern Firefox add-ons, sometimes called WebExtensions. In short, extensions have a manifest.json
that describe what it does, and additional files referenced from there.
In the manifest.json
, you need to add a theme_experiment
that will allow mapping images and other properties to CSS that applies to the main window. We need to do this since Thunderbird as of version 101 does not have a built-in way to define backgrounds for calendar.
Therefore, we want to create a new theme property that allows setting a background image. Here is a full example:
{
"manifest_version": 2,
"name": "Bacon Calendar",
"author": "Philipp Kewisch",
"description": "Add some bacon to your calendar",
"version": "1.0.0",
"icons": {
"16": "addon.svg"
},
"theme_experiment": {
"stylesheet": "style.css",
"images": {
"calendar_view_frame": "--calendar-view-frame"
}
},
"theme": {
"images": {
"calendar_view_frame": "wing-rib-1024-768.jpg"
}
}
}
In this manifest we've referenced three files: addon.svg
is the icon for the extension, style.css is the extra CSS that gets applied to the main window, and wing-rib-1024-768.jpg
will be our background image. The following CSS works at the moment:
#view-box > * {
background-image: var(--calendar-view-frame);
background-size: cover;
padding: 0;
}
calendar-month-day-box, calendar-event-column {
opacity: 0.8;
}
Put all of these files into one directory and zip them together, then you can install it as an extension. Now, you will have some meat in your calendar.
If you would like to add different CSS, or the CSS above is no longer valid, you can use the Developer Tools' inspector to find the right rules. This works similar to the web developer tools, but for the whole Thunderbird window. You can find it in the Tools menu.
Legacy Extensions
For reference, my original answer from 8 years ago used the legacy extensions format. It worked similarly, but the files were a bit different. These extensions had a chrome.manifest, you need to add a style overlay that overlays chrome://messenger/content/messenger.xul. This will allow you to overlay a CSS file, where you just need to add the right rules. Back then, this was the required CSS:
#view-deck > * {
background-image: url(http://baconmockup.com/800/600);
background-size: cover;
padding: 0;
}
calendar-month-day-box, calendar-event-column {
opacity: 0.8;
}
If you want the images to be in each day box instead, just adapt the rules a bit. I'll leave the week view as an exercise.
calendar-month-day-box {
background-image: url(http://baconmockup.com/200/130);
background-size: cover;
}
How to integrate a Thunderbird extension with Lightning
Update 2022 - MailExtensions
There is a better way to do this with newer versions of Thunderbird.
First of all, you need to create the basic Thunderbird extension layout. This is the same layout as in modern Firefox add-ons, sometimes called WebExtensions. In short, extensions have a manifest.json
that describe what it does, and additional files referenced from there.
In the manifest.json
, you need to add a theme_experiment
that will allow mapping images and other properties to CSS that applies to the main window. We need to do this since Thunderbird as of version 101 does not have a built-in way to define backgrounds for calendar.
Therefore, we want to create a new theme property that allows setting a background image. Here is a full example:
{
"manifest_version": 2,
"name": "Bacon Calendar",
"author": "Philipp Kewisch",
"description": "Add some bacon to your calendar",
"version": "1.0.0",
"icons": {
"16": "addon.svg"
},
"theme_experiment": {
"stylesheet": "style.css",
"images": {
"calendar_view_frame": "--calendar-view-frame"
}
},
"theme": {
"images": {
"calendar_view_frame": "wing-rib-1024-768.jpg"
}
}
}
In this manifest we've referenced three files: addon.svg
is the icon for the extension, style.css is the extra CSS that gets applied to the main window, and wing-rib-1024-768.jpg
will be our background image. The following CSS works at the moment:
#view-box > * {
background-image: var(--calendar-view-frame);
background-size: cover;
padding: 0;
}
calendar-month-day-box, calendar-event-column {
opacity: 0.8;
}
Put all of these files into one directory and zip them together, then you can install it as an extension. Now, you will have some meat in your calendar.
If you would like to add different CSS, or the CSS above is no longer valid, you can use the Developer Tools' inspector to find the right rules. This works similar to the web developer tools, but for the whole Thunderbird window. You can find it in the Tools menu.
Legacy Extensions
For reference, my original answer from 8 years ago used the legacy extensions format. It worked similarly, but the files were a bit different. These extensions had a chrome.manifest, you need to add a style overlay that overlays chrome://messenger/content/messenger.xul. This will allow you to overlay a CSS file, where you just need to add the right rules. Back then, this was the required CSS:
#view-deck > * {
background-image: url(http://baconmockup.com/800/600);
background-size: cover;
padding: 0;
}
calendar-month-day-box, calendar-event-column {
opacity: 0.8;
}
If you want the images to be in each day box instead, just adapt the rules a bit. I'll leave the week view as an exercise.
calendar-month-day-box {
background-image: url(http://baconmockup.com/200/130);
background-size: cover;
}
Debug handing thunderbird lightning
You can use the remote debugging capabilities to capture a profile. This should be working even if most things are hanging, but from what you wrote it seems you've tried. If the problem is that you cannot access the dialog that asks to accept the connection, you can set a few devtools prefs to auto-accept connections. I believe this is devtools.debugger.prompt-connection
which needs to be set to false.
Regarding logging, you can enable calendar.debug.log
and calendar.debug.log.verbose
in the advanced config editor. You can then set XRE_CONSOLE_LOG
to output the console to a file. There is a page (although not official, or at least outdated) on debugging xulrunner apps. This pretty much applies to Thunderbird too.
You may also be lucky in contacting the Lightning maintainer to discuss debugging this, he is available on irc.mozilla.org #calendar and is named Fallen.
How can I hack the Thunderbird Lightning extension to fully color categories
The category-overlay.png image is merely a gradient overlay to give the category bar the right looks.
Two options here. One more easy but not as reliable, the other a bit more difficult:
Option A: Easy
Create a userChrome.css in your $profile/chrome/ directory. It should contain the following:
.calendar-color-box[categories~="mycategory"],
.calendar-event-box-container[categories~="mycategory"] {
background-color: #abc123 !important;
}
You'll need to do this for each category you'd like to change the color for. Note that changing the color of the category in the Lightning options won't change the category color you set here.
Option B: More complete
You'll need to modify some files inside lightning.xpi here. This solution merely requires you to set the category colors in Lightning and will also work for newly added categories. Note that this way events without a category are transparent, if you want more you'll have to do it on your own.
- Open lightning.xpi with a zip program
- Enter the directory chrome/
- Open the containing calendar.jar with a zip program
- Descend into content/calendar/
- Open calendar-multiday-view.xml
- search "calendar-color-box" and remove it from the class attribute
- a few lines above there is a <content> tag, add class="category-color-box" to it
- Open calendar-month-view.xml and calendar-view-core.xml and do the same
- Save the files back to calendar.jar
- Save calendar.jar back to lightning.xpi
- Install the modified lightning.xpi
If you'd rather see a patch, this applies to the latest comm-central source:
diff --git a/calendar/base/content/calendar-month-view.xml b/calendar/base/content/calendar-month-view.xml
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -52,21 +52,20 @@
<bindings id="calendar-month-view-bindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-month-day-box-item" extends="chrome://calendar/content/calendar-view-core.xml#calendar-editable-item">
- <content mousethrough="never" tooltip="itemTooltip">
+ <content mousethrough="never" tooltip="itemTooltip" class="category-color-box">
<xul:vbox flex="1">
<xul:hbox>
<xul:box anonid="event-container"
- class="calendar-color-box"
xbl:inherits="calendar-uri,calendar-id"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
class="calendar-event-box-container"
xbl:inherits="readonly,flashing,alarm,allday,priority,progress,status,calendar,categories"
flex="1">
<xul:hbox class="calendar-event-details">
diff --git a/calendar/base/content/calendar-multiday-view.xml b/calendar/base/content/calendar-multiday-view.xml
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -2119,20 +2119,19 @@
]]></handler>
</handlers>
</binding>
<!--
- An individual event box, to be inserted into a column.
-->
<binding id="calendar-event-box" extends="chrome://calendar/content/calendar-view-core.xml#calendar-editable-item">
- <content mousethrough="never" tooltip="itemTooltip">
+ <content mousethrough="never" tooltip="itemTooltip" class="category-color-box">
<xul:box xbl:inherits="orient,width,height" flex="1">
<xul:box anonid="event-container"
- class="calendar-color-box"
xbl:inherits="orient,readonly,flashing,alarm,allday,priority,progress,status,calendar,categories,calendar-uri,calendar-id"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
align="stretch"
class="calendar-event-box-container"
flex="1"
xbl:inherits="context,parentorient=orient,readonly,flashing,alarm,allday,priority,progress,status,calendar,categories">
diff --git a/calendar/base/content/calendar-view-core.xml b/calendar/base/content/calendar-view-core.xml
--- a/calendar/base/content/calendar-view-core.xml
+++ b/calendar/base/content/calendar-view-core.xml
@@ -46,21 +46,21 @@
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-editable-item">
<content mousethrough="never"
tooltip="itemTooltip"
- tabindex="-1">
+ tabindex="-1"
+ class="category-color-box">
<xul:vbox flex="1">
<xul:hbox>
<xul:box anonid="event-container"
- class="calendar-color-box"
xbl:inherits="calendar-uri,calendar-id"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
class="calendar-event-box-container"
flex="1"
xbl:inherits="readonly,flashing,alarm,allday,priority,progress,status,calendar,categories">
<xul:hbox class="calendar-event-details">
Option C: Change Javascript
This would be the best working hack, although it requires javascript changes. Open calendar.jar as described in Option B and check out calendar-views.js, there are two functions: updateStyleSheetForViews()
and updateStyleSheetForCategory()
. I'll leave this to people that want to tinker with it themselves, but the idea would be to add a rule for .calendar-color-box[categories~=...]
that overrides the default rule in case there are categories. This way if there is no category set, the calendar color is used, otherwise the desired category color.
Have fun :)
Thunderbird with lightning not reading valid ics file
You could run the ics through a few validators in case you have not:
http://severinghaus.org/projects/icv/
http://icalvalid.cloudapp.net/
http://mozilla-comm.github.io/ical.js/validator.html
In Lightning, make sure you are using iCalendar / WebDAV when subscribing to the calendar. You can also use the advanced config editor (Options -> Advanced -> General -> Config Editor
) to enable the preferences calendar.debug.log
and calendar.debug.log.verbose
.
Related Topics
How to Add Linear-Gradient Color to Slider
Using Rems with a Pixel Fallback
Unexpected Empty Space Using Flexbox
Why Does Input's Size Increase in CSS Grid Layouts
Understanding The Z-Offset in Transform-Origin
Detect Screen Width with CSS Media Queries
Left/Right Transparent Cut Out Arrow
Background Image Width Not 100% on Ipad
Make an Image Fit Its Container by Setting The Image Height to The Containers Heights
Is a CSS Reset Still Necessary
Chrome Dev Tools Showing a CSS Rule on a Grey Background. Why
Media Queries Running Weird Because of Non-Integer Width
Flexbox Does Not Work in Safari, Striked Out in Web Inspector
CSS Targetting The Last of a Class Type That Isn't The Last-Child
How to Make The Native 'Browse' Button on a File Input Larger Cross Browser