Toggling light/dark “mode” under Linux
I have been using so-called “dark mode” way back in 2005, before everyone starting to hop on that trend since 2017 or so. Nowadays, most Desktop Environments change the color theme automatically, and Emacs packages exist to adjust the editor colorscheme.
However, I have built my custom solution over the years and will likely stick
with it, because I prefer to use plain window managers over DEs. It works as a
switch-color.sh
script, which is automatically called by redshift (or on
demand via shortcut) and toggles light/dark in:
- GTK Applications
- Qt Applications
- The XFCE Terminal
- Emacs
- Applications that respect dconf, like Firefox.
Basically, the script stores a variable “DARK=1” or “DARK=0” in a shell environment file and reads this back when executed. Then, it sets the colors as follows:
# Xfce terminal: Dark
xfconf-query -c xfce4-terminal -p /color-foreground -s "#dededd"
xfconf-query -c xfce4-terminal -p /color-background -s "#002b36"
# Emacs
ln -fs colors-dark.el ~/.emacs.d/colors.el
# GTK Theme / For applications that respect dconf/gsettings
gsettings set org.gnome.desktop.interface color-scheme prefer-dark
gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark
# Qt
sed -i '/^style=Adwaita/style=Adwaita-Dark/' ~/.config/qt6ct/qt6ct.conf
# cinnamon
dconf write /org/cinnamon/desktop/interface/gtk-theme "'Adapta-Nokto'"
As you can see, it is just a matter of using the config-tools to change the respective settings. Except for Emacs, all applications support switching the theme live without restarting.
In Firefox, websites even toggle the colors live. The only requirement is that a gsd-settings daemon is running.
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
(defun my-org-hook-for-repeat-not-on-weekend()
(when (org-property-values "NO_WEEKEND")
;; Get time from item at POINT
(let* ((scheduled-time (org-get-scheduled-time (point)))
;; Convert to timestamp - required for the next step
(seconds-timestamp (time-to-seconds scheduled-time))
;; Convert to decoded time - required to find out the weekday
(decoded-time (decode-time seconds-timestamp))
;; Get weekday
(weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook 'org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend)
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
(defun my-org-hook-for-repeat-not-on-weekend()
(when (org-property-values "NO_WEEKEND")
;; Get time from item at POINT
(let* ((scheduled-time (org-get-scheduled-time (point)))
;; Convert to timestamp - required for the next step
(seconds-timestamp (time-to-seconds scheduled-time))
;; Convert to decoded time - required to find out the weekday
(decoded-time (decode-time seconds-timestamp))
;; Get weekday
(weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
``` (defun my-org-hook-for-repeat-not-on-weekend() (when (org-property-values “NO_WEEKEND”) ;; Get time from item at POINT (let* ((scheduled-time (org-get-scheduled-time (point))) ;; Convert to timestamp - required for the next step (seconds-timestamp (time-to-seconds scheduled-time)) ;; Convert to decoded time - required to find out the weekday (decoded-time (decode-time seconds-timestamp)) ;; Get weekday (weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
```lisp (defun my-org-hook-for-repeat-not-on-weekend() (when (org-property-values “NO_WEEKEND”) ;; Get time from item at POINT (let* ((scheduled-time (org-get-scheduled-time (point))) ;; Convert to timestamp - required for the next step (seconds-timestamp (time-to-seconds scheduled-time)) ;; Convert to decoded time - required to find out the weekday (decoded-time (decode-time seconds-timestamp)) ;; Get weekday (weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
```lisp (defun my-org-hook-for-repeat-not-on-weekend() (when (org-property-values “NO_WEEKEND”) ;; Get time from item at POINT (let* ((scheduled-time (org-get-scheduled-time (point))) ;; Convert to timestamp - required for the next step (seconds-timestamp (time-to-seconds scheduled-time)) ;; Convert to decoded time - required to find out the weekday (decoded-time (decode-time seconds-timestamp)) ;; Get weekday (weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
```lisp (defun my-org-hook-for-repeat-not-on-weekend() (when (org-property-values “NO_WEEKEND”) ;; Get time from item at POINT (let* ((scheduled-time (org-get-scheduled-time (point))) ;; Convert to timestamp - required for the next step (seconds-timestamp (time-to-seconds scheduled-time)) ;; Convert to decoded time - required to find out the weekday (decoded-time (decode-time seconds-timestamp)) ;; Get weekday (weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
```lisp (defun my-org-hook-for-repeat-not-on-weekend() (when (org-property-values “NO_WEEKEND”) ;; Get time from item at POINT (let* ((scheduled-time (org-get-scheduled-time (point))) ;; Convert to timestamp - required for the next step (seconds-timestamp (time-to-seconds scheduled-time)) ;; Convert to decoded time - required to find out the weekday (decoded-time (decode-time seconds-timestamp)) ;; Get weekday (weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Skipping weekends when scheduling items with org-mode
I am using the agenda feature of org-mode quite heavily to plan the things I need to do.
This includes recurring items that I need to do every day or every other day. For these,
I use the +1d
or +2d
syntax respectively. However, this sometimes causes items to being
scheduled on Saturday or Sunday, which is something I don’t want for things I do
at the office.
Interestingly, I could not find anything about scheduling items only from Mon-Fri, besides non-solutions such as “create 5 items for each day and schedule them weekly”.
So I had to come up with my own solution:
```lisp (defun my-org-hook-for-repeat-not-on-weekend() (when (org-property-values “NO_WEEKEND”) ;; Get time from item at POINT (let* ((scheduled-time (org-get-scheduled-time (point))) ;; Convert to timestamp - required for the next step (seconds-timestamp (time-to-seconds scheduled-time)) ;; Convert to decoded time - required to find out the weekday (decoded-time (decode-time seconds-timestamp)) ;; Get weekday (weekday (decoded-time-weekday decoded-time)))
(when (> weekday 5) ;; Saturday -> move to Sunday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 2))))
(when (> weekday 6) ;; Sunday - move to Monday
(setq decoded-time
(decoded-time-add decoded-time (make-decoded-time :day 1))))
(let ((encoded-time (encode-time decoded-time)))
(org-schedule nil encoded-time))
))
)
(add-hook ‘org-todo-repeat-hook 'my-org-hook-for-repeat-not-on-weekend) ```
This code snippet adds a hook, which is executed whenever a repeated
item is re-scheduled. If it has the property NO_WEEKEND
, it checks the
scheduled date and moves it appropriately. Feel free to copy it
under the GPLv3 if this is useful for you.
tags: emacs
Blogging with Emacs on tilde.team
When blogging on tilde.team, I really like the small bb
utility for posting,
as it handles both WWW and Gopher easily. However, I don’t like writing my
posts over SSH - mainly because my GUI Emacs is nicer to use when it comes
to key bindings.
Therefore I decided to create a small script or similar for posting from my desktop emacs. This post contains the steps that I use, in case someone wants to do the same.
Just write markdown
As an Emacs user, I am of course heavily using org-mode. So I thought on writing my blog posts in org and export them as markdown. However, that adds some additional challenges:
- The markdown export from org creates some weird, empty HTML links in the file (reason unknown).
- The first line in the file is the title of the post, without any formatting (e.g.
#
). - The last line contains the tags. These are stored in org usually at the top.
So naturally I thought of using an elisp macro, a shell script or similar to make the required adjustments after the markdown export from org, but then I decided just to write markdown. That saves me all the headache of maintaining another piece of (very small) software.
Post over SSH
For posting the finished post over SSH, I thought of using either tramp, eshell, a regular shell script or a combination of them.
In the end, I decided that a very simple elisp snippet:
(defun blog-post() (interactive) (shell-command (format "scp %s tilde:" (buffer-file-name)) nil nil) (async-shell-command (format "ssh tilde bb post %s" (buffer-name))) )