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 look at sudo man page pointed me to the right direction. sudo has an option that let's you specify another program to ask for password. Perfect. The command line option is
-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
.
No comments:
Post a Comment