So what do? Well simple enough, make a script that relays the openings to different browsers.
#!/usr/bin/env python3
# Link-Relay: Open some links in different browsers. Set the Browser Relay as your default browser.
import os
import re
import sys
def get_browser(link):
mappings = {
"work": {
"browser": "google-chrome --profile-directory=Default",
"urls": ["work", "docs\.google", "forms", "drive"]
},
"customer": {
"browser": "google-chrome --profile-directory='Profile 1'",
"urls": ["sap", "outlook", "portal", "github", "microsoftonline", "sharepoint", "customer"]
}
}
default = "firefox"
for (k, v) in mappings.items():
for url in v["urls"]:
if re.search(url, link):
return v["browser"]
return default
if __name__ == '__main__':
link = sys.argv[1]
app = get_browser(link)
os.system("%s '%s'" % (app, " ".join(sys.argv[1:])))
Save this script to /usr/local/bin/link-relay.py
(or wherever you want to store these) and make it executable. Update the Exec path below if you do.
Tha mappings
variable contains urls that relay to which browser. Here, all google stuff to Chrome Default browser, MS
related to customer profile, and everything else to Firefox.
Then you need a desktop file for the browser to register is at your default:
So create ~/.local/share/applications/browser-relay.desktop
:
[Desktop Entry]
Name=Browser Relay
Comment=Sends some applications to different browsers
Keywords=browser;
Type=Application
Exec=/usr/local/bin/link-relay.py %u
Terminal=false
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
Then run update-desktop-database
, set “Browser Relay” as your default browser and your done! Simply updating the mappings table will update the configuration immediately.
I use org mode for my brain management, it collects and tracks all my TODOs, organizes my workflows and acts as a scratch pad for my code snippets and much more. To capture text and links from browsers, there’s org-protocol in Emacs which allows external tools to invoke org mode, This is in turn used by Org Capture extension to transfer the data into org.
After upgrading Ubuntu to 22.04 Org Capture is once again broken on Firefox. Let’s try to figure out why.
emacsclient -n "org-protocol:///capture?url=http%3a%2f%2fduckduckgo%2ecom&title=DuckDuckGo"
Success! Emacs opens the template windows. I knew this would work, since Org Capture still works on Chrome.
Manage Extension->Preferences->Debug. Save.
> Capturing the following URI with new org-protocol: org-protocol://capture?template=L&url=https%3A%2F%2Fduckduckgo.com%2F&title=DuckDuckGo%20%E2%80%94%20Privacy%2C%20simplified.&body=
So the add-on works.
$ xdg-mime query default x-scheme-handler/org-protocol
emacsclient.desktop
$ xdg-open "org-protocol://capture?template=L&url=https%3A%2F%2Fduckduckgo.com%2F&title=DuckDuckGo%20%E2%80%94%20Privacy%2C%20simplified.&body="
Success! So that works. Again, this is expected as it works on Chrome.
Now that I have the developer console open I can browse into the code and set a breakpoint to capture.js:56
, the
location where it tries to send Firefox to the org protocol URI with location.href = uri
.
The uri is "org-protocol://capture?template=L&url=https%3A%2F%2Fduckduckgo.com%2F&title=DuckDuckGo%20%E2%80%94%20Privacy%2C%20simplified.&body="
.
I can invoke location.href = uri
and sure enough, nothing happens. So now I know it doesn’t understand the org-protocol
protocol, or does nothing with it.
The instructions on setting this up seem a bit vague, so let’s try to understand the entire thing. So off to Register Protocol Documentation. The instructions say (for non gconf users):
Firefox 3.5 and above
(Works without installed Gnome libraries)
- Type about:config into the Location Bar (address bar) and press Enter.
- Right-click -> New -> Boolean -> Name: network.protocol-handler.expose.foo -> Value -> false (Replace foo with the protocol you’re specifying)
- Next time you click a link of protocol-type foo you will be asked which application to open it with.
Not encouraging that the instructions talk about version 3.5 and the page was last modified on 2011. My version is 101.0.1. But let’s continue anyway, it did work very recently anyway. Since I have done this already and I’m in regression mode, It’s double checking mode.
Dead end. I tried the gconf commands as well with no avail.
No effect.
Re-reading org-protocol documentation gave no new insight.
Let’s create a web page to test:
<html>
<a href="org-protocol://capture?template=L&url=https%3A%2F%2Fduckduckgo.com%2F&title=DuckDuckGo%20%E2%80%94%20Privacy%2C%20simplified.&body=">Org link</a>
</html>
Works on Chrome. Not that this is any different from invoking location.href
.
There was, clearing it I was able to see the “launch external app” dialog to appear, but after that nothing.
So now I know that FF does understand the protocol, but for some reason it fails to invoke the xdg-open
or whatever mechanism it uses to launch the external tool.
Hmm.. snap has changed. Could it be? No.. Could it? Googling.. Sure enough, it has issues. So next test install Firefox with deb.
Works like charm.
F you snap.
I don’t want to start this all over but my guess is:
Can it be made to work with snap? By that snap thread it should work(?) but doesn’t. I don’t know or care. There’s a bug to track. I’m out.
]]>What also helps is - weirdly enough - typing. More specifically typing text that you don’t normally type which in my case is prose. My current go-to is typelit.io which allows you to type classic literature. Heck I’ve read many books practicing typing with it!
]]>Just as I was finishing Catch 22 - a book that felt more like a chore than enjoyable, I happened to listen the Econtalk episode on Kenny G with Penny Lane. In it Russ refers to Hegel’s Aesthetics and how it narrowed the Western definition of art to mean something that is difficult, though provoking and challenging. Something simply enjoyable cannot be art by almost definition.
The book appears on many lists of literary classics and it no doubt checks many of the boxes Hegel laid out for good art. Difficult, though provoking and challenging indeed. Confusing with a paper thing plot I’d say. Personally if this makes books art, a reminder for myself not read books that are considered good art. The books sure has some fancy writing, but I’m not after long form poetry in Novel form. I want something that keeps me engaged. This one felt like it would’ve made it’s point if half the pages. War Sucks.
]]>On the “just the follow the characters” method my biggest worry is the endings, which they did get into albeit very briefly. Many authors that write this way write excellent characters with compelling beginnings only to have the story fall flat in the end. Case in point King or Lost (JJ. Abrams) mentioned in the podcast. For Abrams this is especially flagrantly evident in his Mystery Box TED Talk. Nice idea, just expect to be disappointed in the end.
]]>This Econtalk episode was again rather non economic which is find. Here are my On telling compelling stories:
People don’t care about what you do, they care why you do it. It’s what differentiates you from everybody else.
This is always something I will try to keep in mind when making things like presentations. Don’t try to squeeze out the human from your ideas. People can get the facts in seconds if they wish, but to make them stick they need to be compelling.
Second one as a reminder from Kahnemann:
From most experiences we remember the peak moment and the end.
While a bit contested research, I like to think this is also something nice to keep in mind. Actually have a peak moment and think about a proper ending.
]]>The third and final installment in the Remembrance of Earth’s Past trilogy. Where the first one - The Three Body
Problem - was still rather straight forward scifi with an orient perspective, the next two press on the hard scifi
button harder and the deep end gets deeper. This one picked up where the second book left off. Again my inherent
racism unfamiliarity with Chinese names got the best of me - I got lost multiple times on the characters. Xe? Ji?
Li? But the book was certainly long enough to get you back on track. The symbolism used (sword bearers etc.) was still
rather foreign but it made it all the more interesting.
The scifi certainly gets awesomely bat shit crazy in the end, which was to be expected. Dimensions come and go, millions of years are jumped.
4/5.
]]>* Generic TODO
:PROPERTIES:
:DESCRIPTION: Generic TODO item in the Inbox
:KEY: t
:TYPE: entry
:TARGET: file+headline "~/Org/todo.org" "Inbox"
:END:
** TODO %?
* TODO Email
:PROPERTIES:
:DESCRIPTION: TODO mu4e emails with a deadline in two days
:KEY: P
:TARGET: file+olp "~/Org/todo.org" "Inbox"
:OPTIONS: :empty-lines 1
:END:
** TODO %:fromname: %a %?
DEADLINE: %(org-insert-time-stamp (org-read-date nil t "+2d"))
* Add new capture template
:PROPERTIES:
:KEY: M
:TARGET: file "~/Org/capture.org"
:DESCRIPTION: Add new capture template. Prompt for key and description
:END:
** %^{Capture name}
%^{KEY}p%^{TARGET|file "~/Org/todo.org"}p%^{DESCRIPTION}p
*** %?
This configuration creates 3 templates (main level), “Generic TODO”, “TODO Email” and “Add new capture template”. The last one can be used to add more capture templates for example.
While this format should be rather self evident for anyone familiar with capture templates, here is an explanation:
For me, no. I didn’t do any benchmarks other than observed that the initial package load time was shaved a couple seconds (7->4s, 145 packages). If this is meaningful to you, check it out. The subjective experience is all that matters to me in this regard and any speedup must be considerably faster if the price is something breaking. And in day to day usage, I noticed next to nothing.
Performance wise the biggest pain points for me are JSON, which I have to deal with a lot, and lsp-mode. Emacs 27, which I use if I’m not on the nativecomp branch, has better JSON performance already compared to 26, but sadly lsp-mode is as unusable (for Typescript) in both branches. If there’s something that can be done to improve the performance of it, the solution is not GccEmacs.
Here is a short list of things that were broken on my setup:
But recently (March 2021) it seems that now the pace of changes on 28 itself has exceeded the pace package maintainers have been able to fix the breaking changes. When even straight.el gave up, it’s time to go back Emacs 27.
Just to have a clean environment I removed all installed packages and reinstalled them. Only one breakage when downgrading: Org mode prohibited me from exiting Emacs 27 due to some deprecated function alias removal:
(unless (boundp 'org-clocking-buffer)
(defalias 'org-clocking-buffer #'org-clock-is-active))
I’m not sure whether this is an artifact of packaged org mode and the natively included on or some incompatibility with Emacs 27. I’m back to a function org-journal again.
]]>