Pages

Saturday 22 September 2018

Fix Network Device Name for Wireless USB Dongle on Linux

Bought an el-cheapo TP-LINK TL-WN722N for my Desktop Machine. Wanted to ask udev to give the name stick for this device.

  • Plug it in
  • lsusb -> Seeing it's at Bus 001 Device 005: ID 2357:010c TP-Link TL-WN722N v2
  • ip l to display what is the device's name -> wlp0s20f0u3
  • Get udev information on it: udevadm info -a -n /dev/bus/usb/001/005
  • Get the HW address: cat /sys/class/net/wlp0s20f0u3/address
  • Add SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="HWADDR-COMES-HERE", NAME="stick" to /etc/udev/rules.d/10-network.rules
Special thanks for this:
https://wiki.archlinux.org/index.php/Network_configuration#Change_interface_name

Saturday 2 December 2017

Edit Chrome preferences to get to Ctrl+Tab

I wanted to set Ctrl+Tab as a shortcut in Chrome to jump between the two most recent tabs. There is an extension that lets you do it. It is called "Recent Tabs". For me setting the shortcut to Ctrl-Tab wasn't possible through the UI. Use this instead:

cd [YOUR CHROME PROFILE DIR]
vi Default/Preferences

Problem is that Chrome just overwrites that setting every time. So what I had to do is add this line to my startup shell script

sed -i "s,Ctrl+Q,Ctrl+Tab,g" "$DATA_DIR/Default/Preferences"

Friday 1 December 2017

Desktop notifications for dwm

I decided to configure desktop notifications for my environment. I ended up choosing dunst

Follow these instructions and join me using dunst!

To send an example notification

notify-send 'Hello world!' 'This is an example notification.' --icon=dialog-information

Thursday 21 September 2017

Attribute path for chef searches

Do I need to specify the full path for the attribute when doing a search in chef?

Given that you have a node with some attributes (see that fqdn is a nested attribute)

root@crowbar:~ # knife node show d52-54-77-77-01-01.virtual.cloud.suse.de -F json | head
{
  "name": "d52-54-77-77-01-01.virtual.cloud.suse.de",
  "chef_environment": "_default",
  "run_list": [
    "role[crowbar-d52-54-77-77-01-01_virtual_cloud_suse_de]"
  ],
  "normal": {
    "fqdn": "d52-54-77-77-01-01.virtual.cloud.suse.de",
    "crowbar": {
      "network": {

You want to do some searches:

root@crowbar:~ # knife search node 'name:d52-54-77-77-01-01.virtual.cloud.suse.de' -i
1 items found


d52-54-77-77-01-01.virtual.cloud.suse.de

And if you are interested in the fqdn, you do not need to specify the full path:

root@crowbar:~ # knife search node 'fqdn:d52-54-77-77-01-01.virtual.cloud.suse.de' -i
1 items found

d52-54-77-77-01-01.virtual.cloud.suse.de




Wednesday 30 August 2017

Adding a new node to a role in crowbar

I had some issues with the swift proposal. Proxy nodes were clustered but not all nodes of the cluster were part of the storage nodes. Therefore it always failed with a message like:

See that the proposal has issues:

crowbarctl proposal show --format=json swift default > swift.json

The relevant part:
      "elements": {
        "swift-dispersion": [
          "d52-54-77-77-01-01.vh6.cloud.suse.de"
        ],
        "swift-proxy": [
          "cluster:data"
        ],
        "swift-ring-compute": [
          "d52-54-77-77-01-01.vh6.cloud.suse.de"
        ],
        "swift-storage": [
          "d52-54-77-77-01-05.vh6.cloud.suse.de",
          "d52-54-77-77-01-03.vh6.cloud.suse.de",
          "d52-54-77-77-01-04.vh6.cloud.suse.de",
          "d52-54-77-77-01-02.vh6.cloud.suse.de"
        ]

      },

Then edit the file, so you create a swift-new.json like so:

{
  "deployment": {
    "swift": {
      "elements": {
        "swift-storage": [
          "d52-54-77-77-01-05.vh6.cloud.suse.de",
          "d52-54-77-77-01-03.vh6.cloud.suse.de",
          "d52-54-77-77-01-04.vh6.cloud.suse.de",
          "d52-54-77-77-01-01.vh6.cloud.suse.de",
          "d52-54-77-77-01-02.vh6.cloud.suse.de"
        ]
      }
    }
  }
}

And edit the proposal:

crowbarctl proposal edit --merge --file swift-new.json swift default
crowbarctl proposal commit swift default

Rabbitmq Cheatsheet

I am new to rabbit, so here are some notes:

First find out where rabbit api listens:
ss -na | grep 15672

And then get the management cli:
wget  192.168.243.81:15672/cli/rabbitmqadmin
chmod +x rabbitmqadmin

Get a message from a queue:
./rabbitmqadmin --host 192.168.243.81 -u nova -p gD6Yzyvr4E7h  -V /nova get queue=notifications.info

Thursday 25 May 2017

Associate a file extension with an application in Linux

Let's try to associate a file extension to a specific application. For the sake of this example, I would like to associate .somefile to be opened with sublime /usr/bin/subl

Before beginning, let's set a baseline. If you use the xdg-mime utility to query a file's type, you most probably will get something like text/plain. To try this out, let's create a sample file:

touch x.somefile

And then see what the system thinks about this filetype:

xdg-mime query filetype x.somefile

Most probably it will print out something, like text/plain. The first exercise is to change it.
Let's create a new mime type. For this, I'll need to create an xml file, with the name of lakat-somefile.xml (lakat is a vendor string, you might want to replace it with something else):

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/x-somefile">
    <comment>somefile type file</comment>
    <glob pattern="*.somefile"/>
  </mime-type>
</mime-info>

Now let's install this mimetype:

xdg-mime install lakat-somefile.xml

And see that now the type of our dummy file is recognised:

xdg-mime query filetype x.somefile

We are expecting application/x-somefile there. If you are seeing something like inode/x-empty there, you most likely need to install some mime specific packages. In arch linux, what you need is:

sudo pacman -S perl-file-mimeinfo

Once that's done, the next thing to do is to create an "application" that will be used to open this file. If you already have an application, you don't need to do this.

Create a file, called somefile.desktop with the following contents:

[Desktop Entry]
Name=Somefile opener
Comment=Opens with sublime
Exec=/usr/bin/subl
Version=1.0
Type=Application
MimeType=application/x-somefile

now move this file to your home directory, as a per user application:

cp somefile.desktop ~/.local/share/applications/

Now we need to associate the two. Before we do that, let's make sure that we have the correct files in place. Some old applications refer to this config file as  ~/.local/share/applications/mimeapps.list, others refer to it as ~/.config/mimeapps.list. But both should be the same, so let's say that ~/.config/mimeapps.list is a symlink to ~/.local/share/applications/mimeapps.list:

ln -s ~/.local/share/applications/mimeapps.list ~/.config/mimeapps.list

Now before we start to edit this file, let's see what is the situation now, what application is used to open application/x-somefile type files:

xdg-mime query default application/x-somefile

That should yield nothing at the moment. So let's add some associations. Open ~/.config/mimeapps.list, and add something like this:

[Default Applications]
application/x-somefile=somefile.desktop

Now doing the query again, you should see that:

xdg-mime query default application/x-somefile

returns somefile.desktop as expected. Now you should be all set, and you can open your files with xdg-open:

xdg-open x.somefile