The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
2

start script with sudo rights

asked 2013-06-26 13:32:36 +0000

cee gravatar image

updated 2013-06-26 20:18:39 +0000

I have a script to load needed kernel modules and then start virtualbox with 'default' image. It works fine if started from command line, but fails when started through a keyboard shortcut.
Edit:
The problem seems to be that the kernel modules are not loaded in the same shell virtualbox is started. How can I start a (temporary) shell with sudo rights through bindsym shortcut?

line to start script in ~/.3/config


set psst --no-startup-id
bindsym $sup+b exec $psst sudo -u $USER sh -c /develop/scripts/start-vbox.sh

bash script: start-vbox.sh


#!/bin/bash

########################################
# script to start virtual box 
# automatically load kernel modules
# and start virtual win7 image
########################################

cd /home/can/develop/scripts

# load kernel module
sudo modprobe vboxdrv
sudo modprobe -a vboxnetadp vboxnetflt

# start vbox with defined image
vboxmanage startvm Win7x64

Please excuse me, if a similar question already has been posted, but I couldn't figure it out yet.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-06-26 13:43:29 +0000

oblique gravatar image

Install gksu package and replace sudo with gksudo. It will open a GUI to type your password.

edit flag offensive delete link more

Comments

Hi oblique, thanks for your suggestion. I don't mind entering my password into a terminal window. Most of the times I use the fingerprint reader anyway. I will edit my question accordingly.

cee gravatar imagecee ( 2013-06-26 20:12:10 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-26 13:32:36 +0000

Seen: 736 times

Last updated: Jun 26 '13