Tuesday, July 18, 2017

Tiny script for connecting to wireless AP

# Connect to a Wireless Router
# $1 = interface (use ip link)

#!/bin/bash

# Enable the interface
ip link set $1 up
# Find access point names
iw dev $1 scan | grep SSID

# Select SSID and enter password
printf "SSID: "
read SSID
printf "pass: "
read -s PASS

# Connect
TEMPFILE=`mktemp`
wpa_passphrase $SSID $PASS > $TEMPFILE
wpa_supplicant -i $1 -c $TEMPFILE -B
rm $TEMPFILE
dhcpcd $1

Wednesday, May 17, 2017

RTAGS Quick Setup

RTAGS is a tool for C/C++ code navigation and completion (primarily for Emacs). Here's how to get it working quickly on Arch:
  1. Get the tool: git clone https://aur.archlinux.org/packages/rtags-git/ ; cd rtags-git/ ; makepkg -si
  2. Alternatively run `rtags-install` within emacs. 
  3. Start the server: rdm &
  4. Index your project: cd project-code-dir/ ; make -nk | rc -c -
There are a couple of ways to index depending on your build tool (make, cmake etc). 
 Add to .emacs :

(require 'rtags)
(require 'company-rtags)
(setq rtags-completions-enabled t)
(eval-after-load 'company
  '(add-to-list
    'company-backends 'company-rtags))
(setq rtags-autostart-diagnostics t)
(rtags-enable-standard-keybindings)

(define-key c-mode-base-map (kbd "M-.") 'rtags-find-symbol-at-point)
(define-key c-mode-base-map (kbd "M-,") 'rtags-location-stack-back) 



You may want to enable automatic starting of rdm:;; autostart rdm when entering c modes
(add-hook 'c-mode-hook 'rtags-start-process-unless-running)
(add-hook 'c++-mode-hook 'rtags-start-process-unless-running)
 


See also:
https://github.com/Andersbakken/rtags
http://syamajala.github.io/c-ide.html

Saturday, March 18, 2017

Arch installation checklist (i3 desktop)

During basic setup remember to install base-devel as well as base. After basic setup and first reboot:
  1. Check network (ping 8.8.8.8). If down, find adapter name using ip link and enable dhcp using systemctl enable dhcpcd@<adapter name>.service
  2. Add a user:  useradd -m -G groupname -s /bin/bash username. Enable sudo for that user by editing /etc/sudoers.
  3. Install:
    xorg-server  xorg-apps  xorg-xinit  [graphics-driver] #xorg stuff
    i3 dmenu
    lxappearance compton # Desktop environment
    terminator/urxvt firefox git emacs  feh bash-completion #Apps
    dialog wpa_supplicant wpa_actiond #wireless
  4. Setup xorg to autostart i3. Add exec i3 to ~/.xinitrc (cp /etc/X11/xinit/xinitrc ~/.xinitrc).
  5. Setup dot-files for i3, i3status, bash (+aliases), emacs and more (via dotfile repo).
  6. Update X fonts by running lxappearance.
  7. Setup AUR applications (e.g. Dropbox) 
  8. For wireless, generate configurations by running wifi-menu and enable automatic connection management: sudo systemctl enablenetctl-auto@<interface>.service where interface is the name the wireless card (use ip link to see it) .