Bluetooth headset i3block

Recently I purchased a bluetooth headset as I really missed the ability to listen to my music in good conditions. They work quite well and I pretty happy with this wire-free system.

As an i3 window manager user I wanted an easy way to get it connected or disconnected, as I’m also pairing it with my phone. You might already know i3blocks and it’s ability to extend with custom blocks. These days I put together a bluetooth-headset i3block and I already submitted it to the main repository. Meanwhile, you can still get it from my personal clone. And BTW, if you happen to know a means of connecting/disconnecting bluetooth devices on ArchLinux without root access, please share!


Quick tip – sending notifications from the desktop to your phone with kdeconnect-cli

This entry is in the series “script addicts” using I3WM.

Put this in the scripts that are creating notifications:

kdeconnect-cli -d --ping-msg "${notificationMsg}"

That’s it! Now, the notifications will hunt you around if you’re not in front of your workstation.

I3/mutt/offlineimap with decent mail notifications

Today I’ll show you my last trick to get decent email notifications on my I3 environment, without using anything else than offlineimap and mutt. Ok, there’s something else, a couple of scripts but nothing scary.

Before going further, I’d like to ensure you’re using i3blocks. If not, then please configure it then come back and read on.

Until today I was using the classical offlineimap configuration which polled my IMAP server every several minutes directed from a crontab. However, that method has several drawbacks:
– lack of instant mail delivery
– offlineimap would occasionally get stuck upon wifi issues.

Investigating these problems, I found this:

That script was a very good starting point for what follows. So here is the setup:

  • the script ~/bin/ is launched upon I3 session start
    • it calls which would either return a timeout or a string containing the name of the offlineimap account name that has mail, and the folder name
    • it handles the timeouts itself so if or offlineimap gets stuck for some reason, they get killed
    • when new mail is found, it uses notify-send,  then calls offlineimap to retrieve the mail from the specified folder and it updates i3blocks
    • finally, it calls notmuch to get the new mail indexed

Put this script in ~/bin/
chmod +x ~/bin/

Then save this script as ~/bin/ Modify lines 25..27 to suit your configuration. Beware that you should use the same values as in your ~/.offlineimaprc file, if not the scripts will not correctly invoke offlineimap.
chmod +x ~/bin/

Get the i3blocks blocklet command from here and save it to ~/.config/i3blocks/ Then adjust it on line 2 to get it inspect your local mailboxes. Also, adjust line 6 if the directory containing your mails is not ~/Mail.
chmod +x ~/.config/i3blocks/

Activate the blocklet into ~/.config/i3blocks/config:

command= ~/.config/i3blocks/

As you may have noticed, the blocklet will be updated by the other parts of the system using this command:
pkill -SIGRTMIN+12 i3blocks

Hang-on, we’re almost done! 😉

Get the tool activated upon I3 session start by adding this to ~/.config/i3/config:
exec --no-startup-id ~/bin/ &

Stop your current mail retrieval scripts and then restart your I3 session. You should now start having notifications upon new mail arrival. That is, when some of the IMAP folders supervised by get mail, then you should see a dunst (or whatever you use) notification, and the i3blocket should become red, displaying the offlineimap account name containing new mails, with their count.

Last step is getting mutt update the i3blocket upon mail reading. Just add this macro somewhere in your ~/.muttrc:
macro index <F5> "<sync-mailbox>:set wait_key=no\n!pkill -SIGRTMIN+12 i3blocks^M"

Restart mutt and use F5 to sync your maildir and eventually clear the i3blocklet when no unread mail is left.

Posted in i3

Scripting addicts, check the new kwallet-query tool!

This weekend I created a new kwallet tool, named kwallet-query. It now lives in playground/utils for you to try it up. Just issue “kwallet-query –help” after building it to see the available options.

qwallet-query sports two modes: list mode and read value mode. You should specify the mode when invoking the tool, along with the wallet name you want the tool to read. I’d also be glad to hear back from you as to what this tool should provide in addition to this. This initial version will work on KF5-based systems. Should I also add support for the legacy KDE4 wallet?

You may find this tool handy when reading the wallet from other places. For instance, I wanted to create this tool in order to get my passwords from my wallet by using dmenu on my I3WM-enabled KDE session.

For those interested about the dmenu integration thing, have a look at this: It’s a little script that uses the new kwallet-query tool in two phases. First, it’ll send the list of folders you have in the Passwords section of the wallet. It’ll feed the list to dmenu who’ll invite you to select the folder you want to read. A second invocation will read the folder you choose from the wallet and once again will feed dmenu to let you choose one entry, corresponding to one line in the password stored in the kwallet. The selected entry will be pu into the clipboard, so you’ll only have to press Shift+Insert into the application where you where, without further workflow break. No more kwalletmanager visiting to copy/paste your secrets items!

Once again, I’m looking forward for your feeback (bug reports or even comments here). I plan to get this tool through the kdereview process about one month from now.

Connecting mutt to corporate MS Exchange

Last year I finally had the opportunity to install and use Linux at my work. The background of this change is out of the scope of this posting, I can only tell you that I was waiting for it since the very beginning. So I’m a happy Fedora user since a little more than an year, at my work (at home I’m using Linux since 2003 I think – ArchLinux currently).

Working with Linux is quite interesting and productive if you one uses the right tools. That’s why I also configured and a whole bunch of text mode tools, mainly vim plugins (know YouCompleteMe?), but also the Ranger file manager. However, our company uses MS Exchange *without* the IMAP connector and that’s quite a problem, because it interfaces only with MS Outlook or Evolution. MS Outlook has to run under Windows, so I used a virtual machine for this, eating 1 GB of RAM. Evolution runs natively, but it also eats more than 1GB only to present me the mails or some reminders. That’s a serious problem when one uses other very memory-intensive tools like Eclipse, IntelliJ or Oracle SQL Developer, not to mention Maven or DB Solo. So I really needed a solution to reduce my working session’s footprint, to get the most out of my workstation’s 8 Gb of RAM. Some coworkers are using Citrix sessions for that, but that has the mail/workstation integration problem.

Enter davmail. This awesome little project solved a problem several of us have at work: interface an IMAP client with our corporate server. DavMail need a very minimalist configuration. It almost worked out of the box, not considering the need to enter the company’s OWA URL. Once started, I instantly got IMAP and CalDAV. It also provides iCal and CardDAV but I don’t use these so I don’t know how it works. So, I’m now using mutt to handle corporate mails, interface it with lbdb and our LDAP server. \o/

The calendar is handled with khal but I also use remind. This part needs some more work, as I still need to figure out how to create appointments on my machine, then get them synchronized to the corporate server.

Should I write a tutorial with the steps I done so far? Let me know and I’ll do it if you’re interested.

Starting KF5 using the I3 window manager

Lately I started experimenting several tiling window managers, and I settled on I3 (see its Official site and the corresponding ArchLinux wiki page)

I now plan to return hacking KF5 and I’d like to use this tiling manager. In KDE4 I simply used the “Default Applications” control module from “System Settings” to choose i3, after adding the right i3.desktop file. However, with KF5 that will not be enough. For some reason kwin will still be loaded. (And BTW, the new kwin looks really great. I also like the new plasma desktop very much, but it won’t fit my workflow, as I prefer tiling WMs paradigm) Today I started searching a quick way to workaround that and here it is what I did.

Firstly, create the $KF5/share/ksmserver/windowmanagers/i3.desktop file with this contents:

[Desktop Entry]
Comment=Highly configurable framework window manager

Then edit the file ~/.config/ksmserverrc and modify the windowManager line from the [General] section:

# other lines ommited

Alternatively, you can use the “Default Applications” control module from KF5 System Settings to change the window manager to i3.

Finally, here is the little bit that made it. Modify the KF5 startup script to define the KDEWM environment variable. It should read like this:
export KDEWM=/usr/bin/i3

Here is how:
On my system, I’m using kdm. For it to start a KF5 session, I created /usr/share/config/kdm/sessions/kf5.desktop with this contents:

[Desktop Entry]

As you can see, my KF5 is installed in /home/kde5 (others may have it in /opt/kf5). The start-up script, named ‘start-kde’ simply sets the righ environment variables, calls ssh-agent and gpg-agent, then calls startkde from KF5. I added the export KDEWM=/usr/bin/i3 line into this script.

Quit your current session, choose the KF5 session in KDM and enjoy I3 with KF5!

I’ll now return to tinkering it, as some adjustments still need to be done 🙂