dm-tool
utility:dm-tool switch-to-greeter
dm-tool
utility:dm-tool switch-to-greeter
Fix the host name and the user name accordingly. Then add a line like this to /etc/ppp/chap-secrets:remotename myvpn linkname myvpn ipparam myvpn pty "pptp <host> --nolaunchpppd " name <username> usepeerdns require-mppe refuse-eap noauth # adopt defaults from the pptp-linux package file /etc/ppp/options.pptp
<username> myvpn <password> *
/etc/ppp/ip-down.d/myvpn:#!/bin/bash if [[ $PPP_LOCAL = 192.168.2.* ]]; then route del default gw 192.168.1.1 route add default gw 192.168.2.100 fi
Don't forget to make the scripts executable. Also notice that ip-up.d/ and ip-down.d/ are only available in Debian and its derivatives (to learn more about the arguments passed to them and the available environment variables, see the Debian /etc/ppp/ip-up and /etc/ppp/ip-down scripts). Other distros use slightly different paths.#!/bin/bash if [[ $PPP_LOCAL = 192.168.2.* ]]; then route add default gw 192.168.1.1 route del default gw 192.168.2.100 fi
Also, if you like to have tabs, you can run urxvt likeURxvt*background: #000000 URxvt*foreground: #00ff00 ! black URxvt.color0 : #000000 URxvt.color8 : #555555 ! red URxvt.color1 : #AA0000 URxvt.color9 : #FF5555 ! green URxvt.color2 : #00AA00 URxvt.color10 : #55FF55 ! yellow URxvt.color3 : #AA5500 URxvt.color11 : #FFFF55 ! blue URxvt.color4 : #0000AA URxvt.color12 : #5555FF ! magenta URxvt.color5 : #AA00AA URxvt.color13 : #FF55FF ! cyan URxvt.color6 : #00AAAA URxvt.color14 : #55FFFF ! white URxvt.color7 : #AAAAAA URxvt.color15 : #FFFFFF URxvt*font: xft:Monospace:pixelsize=18 URxvt*letterSpace: -1 URxvt.perl-ext-common : default,matcher URxvt.urlLauncher : firefox URxvt.matcher.button : 1 ! scrollbar style - rxvt (default), plain (most compact), next, or xterm URxvt.scrollstyle: plain URxvt.perl-ext-common: default,tabbed
urxvt -pe tabbed
, or you can add this line to your .Xdefaults.URxvt.perl-ext-common: default,tabbedIn order to open a new tab, press C-M-Down (that is, control and alt and down arrow). To switch tabs use C-M-Left and C-M-Right. To move the current tab, use C-Left and C-Right. I wish I could change these key bindings since the arrow keys are two far away from my comfort zone, but I haven't find a way to do that, yet. Well, nothing is perfect!
If you're ever in doubt about the class attribute of a certain window, just switch to it, press(defcommand urxvt () () "Start a urxvt instance or switch to it if already running" (run-or-raise "urxvt" '(:class "URxvt"))) (define-key *root-map* (kbd "c") "urxvt") (define-key *root-map* (kbd "C-c") "urxvt")
C-t :
and then type in (stumpwm::window-class (stumpwm::current-window))
.
Obviously, VLC's telnet interface should be active. I found no way to find out if playback is paused in VLC or not. There are two commands that looked like they should help, but they don't. Telnet command is_playing only returns 0 if playback is stopped, not paused. status command for some reason always says "( state paused )". Anyway, I'm glad that VLC itself can create global key-bindings, so I'm happy with my current situation.;; vlc control. vlc telnet interface should be enabled. (defcommand vlc-play () () "start/resume vlc playback" (telnetlib:with-telnet-session (tn "localhost" 4212) (telnetlib:read-until tn "Password: ") (telnetlib:write-ln tn "admin") (telnetlib:read-until tn "> ") (telnetlib:write-ln tn "play") (telnetlib:read-until tn "> ") (telnetlib:write-ln tn "quit"))) (defcommand vlc-pause () () "pause vlc playback" (telnetlib:with-telnet-session (tn "localhost" 4212) (telnetlib:read-until tn "Password: ") (telnetlib:write-ln tn "admin") (telnetlib:read-until tn "> ") (telnetlib:write-ln tn "pause") (telnetlib:read-until tn "> ") (telnetlib:write-ln tn "quit")))
The check-mail function uses the clonsigna package (for IMAP). When there is unread mail, it sets the SCROLL LOCK LED to blink for one second every five seconds. It also sets the global variable *unread-mail-count* to the number of unread messages.;; mail notification (defvar *unread-mail-count* 0) (defcommand check-mail () () "Checks an email account and if there is unread mail in the inbox makes the scroll lock led to slowly blink. Returns the number of unread messages. Needs the ledcontrol command available and the ledd daemon pipe file (/var/run/ledd-pipe by default) should be accessible by normal users." (let ((sock (clonsigna:make-imap :host "imap.gmail.com" :port 993 :ssl-p t))) (unwind-protect (progn (clonsigna:cmd-connect sock) (clonsigna:cmd-login sock "username" "password") (clonsigna:cmd-select sock "inbox") ;; cmd-search will return something like (("* SEARCH 2461 ;; 2465 2471")) The numbers are message ids, that's why we ;; split the string by spaces, count the parts and then ;; subtract two for the "* SEARCH" part (setf *unread-mail-count* ( - (length (cl-utilities:split-sequence #\Space (first (clonsigna:cmd-search sock :criteria "UnSeen")))) 2)) ;; if there is unread mail, have the scroll lock led blink ;; for one second every five seconds (if (zerop *unread-mail-count*) (run-shell-command "ledcontrol set s9 off") (run-shell-command "ledcontrol set s9 dutycycle 5000 1 100 20")) *unread-mail-count*) (clonsigna:cmd-close sock)))) (defvar *mail-notification-timer* (run-with-timer 1 120 'check-mail))
amixer sset Master 5%+
which simply raises the master volume by 5 percent. That line also prints out the current volume (among other things) which we will use in order to show the user the current volume. I've added this snippet to my .stumpwmrc file:This defines three commands (volume-up, volume-down and volume-mute-toggle) and binds them to the multimedia volume control keys. This works fine on my computer. If the multimedia keys are not available for you, this page suggests adding these lines:;; setup volume control key bindings (defcommand volume-up () () "Increases master volume by 5 percent." (let ((result (run-shell-command "amixer sset Master 5%+" t))) (cl-ppcre:register-groups-bind (pct) ("\\[(\\d+)%\\]" result) (message "~a%" pct)))) (define-key *top-map* (kbd "XF86AudioRaiseVolume") "volume-up") (defcommand volume-down () () "Increases master volume by 5 percent." (let ((result (run-shell-command "amixer sset Master 5%-" t))) (cl-ppcre:register-groups-bind (pct) ("\\[(\\d+)%\\]" result) (message "~a%" pct)))) (define-key *top-map* (kbd "XF86AudioLowerVolume") "volume-down") (defcommand volume-mute-toggle () () "Mutes/Unmutes the master volume." (let ((result (run-shell-command "amixer sset Master toggle" t))) (cl-ppcre:register-groups-bind (state) ("\\[(on|off)\\]" result) (if (equalp state "off") (message "muted.") (message "unmuted."))))) (define-key *top-map* (kbd "XF86AudioMute") "volume-mute-toggle")
UPDATE: I just noticed that the code for mute does not work on my Desktop (with Ubuntu Precise) though it's perfectly fine on my laptop (which runs Debian Squeeze). After some poking around, I found out that apparently when pulseaudio is present, amixer cannot unmute sound. I looked around for a pulseaudio equivalent and found pactl. But unlike amixer, pactl does not print out the current state of things after running a command and it also (as far as I know) does not provide a toggle command. What I did was to run(define-keysym #x1008ff11 "XF86AudioLowerVolume") (define-keysym #x1008ff12 "XF86AudioMute") (define-keysym #x1008ff13 "XF86AudioRaiseVolume")
pactl list
first. This command prints out a lot of information from which we can find out if sound is muted or not. In the following snippet, I'm using a very simplistic regular expression to extract this information. It might not work correctly on a different setup
(defcommand volume-mute-toggle () () "Mutes/Unmutes the master volume." (cl-ppcre:register-groups-bind (state) ("Mute: (yes|no)" (run-shell-command "pactl list" t)) (cond ((equalp state "yes") (run-shell-command "pactl set-sink-mute 0 0") (message "unmuted.")) (t (run-shell-command "pactl set-sink-mute 0 1") (message "muted.")))))
C-t h w
. You'll be prompted for the command you're looking for and if it's bound to a key, you'll know about it. To know more about help options (which all start with the key-binding C-t h
) press C-t h ?
.
$ setxkbmap "pc+us+ir:2+inet(evdev)+group(shifts_toggle)"
I got that line by running setxkbmap -print
on my Ubuntu machine. The output had something that seemed to be what I
want. And I was right! Running that, I noticed that the changes I've
made with xmodmap was reset. Well, all I had to do was to put the line
that runs xmodmap after setxkbmap. Like this:Except that didn't work. I logged out and logged back in, and I saw my alt and ctrl keys are not where they should be. A couple of times running those commands by(run-shell-command "setxkbmap \"pc+us+ir:2+inet(evdev)+group(shifts_toggle)\"") ;; load keyboard map (run-shell-command "xmodmap ~/.xmodmap")
C-x C-e
from
within Emacs gave me an idea what might be wrong. You see, by default,
run-shell-command runs the command given to it asynchronously. I needed
to make sure setxkbmap is done before I move onto xmodmap. Thankfully, run-shell-command
has one last optional argument collect-output-p
.
It's function is to collect the program output, but in doing so it
makes the execution synchronous. So adding that argument fixed the
problem:Voila! Now I can switch layouts like before. Of course, I have no visual indication of the current layout anymore. I'm not 100% sure I want that. I might choose to work out a way for caps lock or scroll lock LED to do that for me later.(run-shell-command "setxkbmap \"pc+us+ir:2+inet(evdev)+group(shifts_toggle)\"" t)
This makes the CAPS LOCK led to turn on when an alternate keyboard layout is active.(run-shell-command "setxkbmap \"pc+us+ir:2+inet(evdev)+group(shifts_toggle)\" -option grp_led:caps" t)
(run-shell-command "xsetroot -cursor_name left_ptr")
C-t !
shortcut. If I want to run it as root, I had to use gksu, but gksu does not exactly fit in the simple look and feel of StumpWM. What I wanted was a way to ask for password in the small box that appears in the top right when StumpWM wants some input.-A
. The program can be specified either in sudo config file or using the environment variable SUDO_ASKPASS
. This script would do the trick:Now we only need the ask.sh script. But how can we get a script to call a StumpWM function? At first, I wanted to write a small server that opens a port and listens for commands. Fortunately, I accidentally learned about stumpish which is a script in StumWM's contrib directory that can send commands to StumpWM and return the results. Here's how ask.sh uses stumpish:#!/bin/bash env SUDO_ASK_PASS=~/bin/ask.sh sudo -A $@
The first argument is the name of a StumpWM command, while the rest are it's parameters. Since, as far as I know, there is no StumpWM command to ask for input, I wrote these two in my .stumpwmrc:#!/bin/bash stumpish stumpwm-password password:
I called the first script;; these commands are mainly intended to be called by external ;; commands through the use of stumpish (defcommand stumpwm-input (prompt) ((:string "prompt: ")) "prompts the user for one line of input." (read-one-line (current-screen) prompt)) (defcommand stumpwm-password (prompt) ((:string "prompt: ")) "prompts the user for a password." (read-one-line (current-screen) prompt :password t))
stu
and put it with ask.sh
in my bin
directory. Now whenever I want to run synaptic, I press C-t !
and type in stu synaptic
.
exec stumpwm
. After that, I switched to a tty by pressing Ctrl-Alt-F1 and ran startx -- :1
. Then I pressed Ctrl-Alt-F8 to switch to the new X screen. It actually worked! I quickly copied my configuration from my laptop and restarted StumpWM. Everything seemed to be working, until I tried to start Firefox.firefox --ProfileManager
. Then to start Firefox with the new profile and as a new instance you can run firefox -no-remote -P profilename
.For some reason, this does not always start swank though. When that happens, I just hit(load "/home/mostafa/slime/swank-loader.lisp") (swank-loader:init) (defcommand swank () () (setf stumpwm:*top-level-error-action* :break) (swank:create-server :port 4005 :style swank:*communication-style* :dont-close t) (echo-string (current-screen) "Starting swank. M-x slime-connect RET RET, then (in-package stumpwm).")) (swank)
C-t ;
and run "swank." I can then connect to the Lisp image by invoking slime-connect
in emacs.This tells StumpWM to run the command "firefox" previously declared by defcommand when I hit(define-key *root-map* (kbd "x") "firefox")
C-t x
. C-t
is StumpWM's prefix key (can be changed of course). Any key-binding added to *root-map*
is should be used after pressing this prefix. If wan't to make a key-binding without the prefix key, I can add it to *top-map*
. This is how the "firefox" command is defined:Remember that the value after :class should be Firefox with a capital F. If it's not written like that, rerunning the command will not raise the current window, but will open a new one. On Debian, :class should be Iceweasel instead of Firefox. (For a short explanation of class and other window attributes in X see here. In short, class name is, by convention, the instance name with the first letter capitalized.);; launch web browser (defcommand firefox () () "start firefox or switch to it if already running." (run-or-raise "firefox" '(:class "Firefox")))
Finally, I need to more things. First, Network Manager seems essential. I'm going to use it's Tray icon at the moment, so since StumpWM doesn't have a tray, I'll use trayer which launches a tray in a floating window. In Debian, trayer can be installed by running;; ask the user for a search string and search for it in Wikipedia (defcommand wikipedia (search) ((:string "Search in Wikipedia for: ")) "prompt the user for a search term and look it up in the English Wikipedia" (check-type search string) (let ((uri (format nil "http://en.wikipedia.org/wiki/Special:Search?search=~a" search))) (run-shell-command (cat "firefox \"" uri "\"")))) ;; ask the user for a search string and search for it in Google (defcommand google (search) ((:string "Search in Google for: ")) "prompt the user for a search term and look it up in Google " (check-type search string) (let ((uri (format nil "http://www.google.com/search?q=~a" search))) (run-shell-command (cat "firefox \"" uri "\""))))
apt-get install trayer
. This launches trayer properly and then runs the Network Manager applet.And then I need to load my own customized keymap (I swap the ctrl and alt keys and make Caps Lock an additional alt).;; system tray (run-shell-command "/usr/bin/trayer --SetDockType false --transparent true --expand false") ;; start network manager applet (run-shell-command "nm-applet --sm-disable")
That's it for now.;; load keyboard map (run-shell-command "xmodmap ~/.xmodmap")
In order to use Terminus as my console (tty) font, I simply installed the package terminus-font with pacman (includes both console and X11 ...