Skip to content

Instantly share code, notes, and snippets.

@girst girst/
Last active Apr 5, 2019

What would you like to do?
`jj` - i3 tool for various tasks

i3tool by


This is a simple program that lets you start programs / perform common tasks with very little key strokes.

Released under the GNU GPLv2. You can download a copy of the license from


Firstly, copy the executable into a directory in your $PATH; optionally name it jj. (from now on, /usr/bin/jj will be assumed)

To enable passwordless sudo, run sudo visudo and append this to the end of the file:

YOUR_USERNAME    ALL=(root)    NOPASSWD: /usr/bin/jj

As this essentially allows priviledge escalation, follow those steps to keep as safe as still possible:

  • make sure to only allow your main user to execute sudo from within jj without password
  • chown root:root $(which jj); chmod 0755 $(which jj), so only root can change the script


Some things look rather ugly, like the 'lock-and-suspend' routine. let me know, if that can be expressed better.

Some of these commands need to be run as root, dnf update for example. If you have configured your sudoers file correctly, the script will detect not being superuser and restarting itself via sudo.

Even though this script is very small, I have released it as GPLv2. Part of the reason is to encourage you to share your modifications and enhancements with others.

# i3 tool for various tasks by (
# Released under the GNU GPLv2; See for the full license terms and conditions.
start_mutt() {
case $1 in
*3) mutt -F ~/.mutt/startaccount2 ;;
*4) mutt -F ~/.mutt/startaccount3 ;;
*2) ;&
*) mutt -F ~/.mutt/startaccount1;;
case $1 in
l) xscreensaver-command -lock ;;
p) poweroff ;;
r) reboot ;;
s) xscreensaver-command -lock &&\
sleep 1.5 &&\
systemctl suspend
w) [ "$(id -u)" != "0" ] && sudo jj w || nmtui ;;
a) alsamixer ;;
m*) start_mutt $1 ;;
u) [ "$(id -u)" != "0" ] && sudo jj u || dnf update ;;
pgrep mopidy >/dev/null 2>&1 || mopidy >/dev/null 2>&1 &
cat <<-EOF
Usage: $0 ACTION
Available Actions:
l lock screen
p power off
r reboot
s suspend (and lock screen)
w wifi / network manager
a alsamixer
m[234] mutt email client (account1, account2, account3)
n mopidy-spotify & ncmpcpp
u dnf update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.