Script: Config Files Menu

Published 05-05-2018 22:59:24

Raw

#!/bin/bash
# A menu script for conveniently accessing config files
# Bound to Mod+F2

# Each menu choice has a file to edit
# or command to run in the MenuCommands() function
MenuChoices=\
"appearance
audio
backup
bash
bookmarks
disks
hosts
i3
i3blocks
input
mpd
mpv
mutt
newsboat
printers
profile
ranger
rss
screens
scripts
ssh
startup
surf
tmux
vim
x
zathura"

MenuCommands(){
	case $chosen in
		appearance)	lxappearance &disown ;;
		audio)		pavucontrol &disown ;;
		backup)		openfile ~/.scripts/tools/backup ;;
		bash)		openfile ~/.bashrc ;;
		bookmarks)	openfile $BOOKMARKS ;;
		disks)		sudo gnome-disks &disown ;;
		hosts)		$runprefix sudo $EDITOR /etc/hosts ;;
		i3)		openfile ~/.config/i3/config ;;
		i3blocks)	openfile ~/.config/i3blocks/config ;;
		input)		lxinput &>/dev/null &disown ;;
		mpd)		openfile ~/.config/mpd/mpd.conf ;;
		mpv)		openfile ~/.config/mpv/input.conf ;;
		mutt)		openfile ~/.config/mutt/muttrc ;;
		newsboat)	openfile ~/.newsboat/config ;;
		printers)	system-config-printer &disown ;;
		profile)	openfile ~/.profile ;;
		ranger)		openfile ~/.config/ranger/rc.conf ;;
		rss)		openfile ~/.newsboat/urls ;;
		screens)	arandr &>/dev/null &disown ;;
		scripts)	$runprefix $FILE ~/.scripts ;;
		ssh)		openfile ~/.ssh/config ;;
		startup)	openfile ~/.scripts/autostart ;;
		surf)		SurfStyles ;;
		tmux)		openfile ~/.config/tmux/tmux.conf ;;
		vim)		openfile ~/.vimrc ;;
		x)		openfile ~/.Xdefaults ;;
		zathura)	openfile ~/.config/zathura/zathurarc ;;
	esac ;}

# The "surf" option will list CSS stylesheet choices
SurfStyles() {
	chosen=$(echo -e "Dark Mode\nSolarized" | $mymenu "Surf stylesheet choice:")
	stylenote() { notify-send "Surf stylesheet changed:" "$chosen" ;}
	case $chosen in
		"Dark Mode")	cp ~/.surf/styles/dark.css ~/.surf/styles/default.css && stylenote ;;
		"Solarized")	cp ~/.surf/styles/solarized.css ~/.surf/styles/default.css && stylenote ;;
	esac
	exit ;}

chosen=$1
runprefix=
mymenu=$(setmenu -l)
amitty=$(tty)
case $amitty in
	*tty1|"not a tty") runprefix="$TERMINAL -e" ;;
esac
[[ -z $chosen ]] && chosen=$(echo -e "$MenuChoices" | sort -n | $mymenu "🔧 Configure")
clear
MenuCommands
exit 0