Browse Source

First commit.

Fabrizio Romano Genovese 7 years ago
commit
5370944f7f
10 changed files with 1051 additions and 0 deletions
  1. 55 0
      README
  2. 63 0
      i3-blur
  3. 105 0
      i3-brightness-toggle
  4. 113 0
      i3-copy-scripts
  5. 102 0
      i3-exit
  6. 84 0
      i3-layout-loader
  7. 99 0
      i3-screensaver-toggle
  8. 130 0
      i3-volume-toggle
  9. 93 0
      i3-xrandr-toggle
  10. 207 0
      notify-send-improved

+ 55 - 0
README

@@ -0,0 +1,55 @@
+##############
+##Background##
+##############
+#Install feh, then give only once:
+feh --bg-scale /usr/share/wallpapers/ColdRipple/contents/images/1920x1080.jpg
+#If it does not work, change the wallpaper path. It could have been removed in a later version of qubes.
+#Use this command with a different path to change background. Once you give it the i3 config file will allow you to remember the configuration at every login.
+#If you lost the i3 config file add this line to make it remember the background:
+exec ~/.fehbg
+
+#install dunst, a lightweight notification system.
+#Then you have to give
+sudo mv /usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service /usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service.disabled 
+#Too disable xfce-notifyid in order to make dunst work. You also have to restart your pc for this change to take effect.
+#In this folder you will also find the dunstrc configuration file you need.
+
+###############
+##Screensaver##
+###############
+#script: i3-lock
+#Just give 'i3-lock' on a terminal and the screensaver will start.
+#Invoke the script with xautolock in the i3 config file.
+
+########################
+##Screen Toggle Script##
+########################
+#script: i3-xrandr-toggle
+#And add this to the i3 config file
+bindsym $mod+F8 exec i3-xrandr-toggle
+
+####################################
+##Log in/out/reboot/.. environment##
+####################################
+#script: i3-exit
+#And add this to the i3 config file
+set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
+mode "$mode_system" {
+    bindsym l exec --no-startup-id i3-exit lock, mode "default"
+    bindsym e exec --no-startup-id i3-exit logout, mode "default"
+    bindsym s exec --no-startup-id i3-exit suspend, mode "default"
+    bindsym h exec --no-startup-id i3-exit hibernate, mode "default"
+    bindsym r exec --no-startup-id i3-exit reboot, mode "default"
+    bindsym Shift+s exec --no-startup-id i3-exit shutdown, mode "default"
+
+    # back to normal: Enter or Escape
+    bindsym Return mode "default"
+    bindsym Escape mode "default"
+}
+bindcode 135 mode "$mode_system"
+
+################
+##Environments##
+################
+
+

+ 63 - 0
i3-blur

@@ -0,0 +1,63 @@
+#!/bin/bash
+
+# This is a simple program that blurs the current screen and uses it as
+# a screensaver. scrot and i3lock have to be installed in order to make it 
+# work. 
+
+# i3-blur - A simple i3lock addon for a blurred screensaver
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-blur 
+# to make it executable.
+
+version=1.0
+
+if [[ "$#" -ge 2 ]]; then
+	echo "Usage: $0 {-v, --version | -h --help}"
+        exit 0
+elif [[ "$#" -eq 1 ]]; then
+	case $1 in
+        -v | --version)
+                echo "$0 - Version $version"
+                exit 0;;
+        -h | --help)
+		echo "This is a simple program that blurs the current screen and uses it as a screensaver. scrot and i3lock have to be installed in order to make it work."
+		echo "- v, --version            Display current version"
+                echo "-h, --help                Display this message"
+		exit 0;;
+ 	*)
+		echo "Usage: $0 {-v, --version | -h, --help}"
+		exit 2;;
+	esac
+fi
+
+# Check if scrot and i3lock are installed
+if [ -f /bin/scrot -a -f /bin/i3lock ]; then
+
+# Take a screenshot
+	scrot /tmp/screenshot.png
+# Blur it
+	convert /tmp/screenshot.png -blur 0x5 /tmp/screenshotblur.png
+# Invoke the i3lock screensaver using it as a background
+	i3lock -f -i /tmp/screenshotblur.png
+else 
+# Abort if they are not
+	echo "i3lock and/or scrot are not installed. Please install them."
+	exit 2
+fi
+
+

+ 105 - 0
i3-brightness-toggle

@@ -0,0 +1,105 @@
+#!/bin/bash
+
+# This script increases/decreases brightness by a fixed increment specified in step.
+# This script relies on the script notify-send-improved.
+
+# i3-brightness-toggle - Increase and decrease brightness.
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-blur 
+# to make it executable.
+
+version=1.0
+step=10
+
+# Check if xbacklight  and notify-send-improved are installed
+check_installed()
+{
+if [ ! -f /bin/notify-send-improved -a -f /bin/xbacklight ]; then
+	echo "Notify-send-improved and/or xbacklight not present."
+        echo "Please install them."     
+        exit 2
+fi
+}
+
+#Here we display the help messages and change the brightness using xbacklight
+if [[ "$#" -ge 2 ]]; then
+        echo "Usage: $0 {-v, --version | -h --help}"
+        exit 2
+elif [[ $# -le 1 ]]; then
+	 case $1 in
+		-v | --version) 
+			echo "$0 - Version $version"
+			exit 0
+			;;
+		-h | --help)
+			echo "- v, --version		Display current version"
+			echo "-h, --help		Display this message"
+			echo "up			Increase brightness by $step%"
+			echo "down			Decrease brightness by $step%"
+			exit 0
+			;;		
+		"up")
+			check_installed
+			xbacklight -steps 1 -time 0 -inc $step
+			;;
+		"down")
+			check_installed
+                        xbacklight -steps 1 -time 0 -dec $step
+			;;
+		*)
+                	echo "Usage: $0 {up|down| -v, --version | -h, --help}"
+                	exit 2
+	esac
+fi
+
+# Here we get the current brightness status from xbacklight
+# awk is necessary because xbacklight is not precise and the 
+# resulting brightness number is always slightly less than it should, 
+# by ~0.05 usually. If we were to use cut instead of awk the result would 
+# then be aesthetically unpleasant.
+
+brightness=`xbacklight | awk '{printf("%d\n", $0+=$0<0?0:0.9)}'`
+
+# Selects the right icon for the notification
+# If the icon is not present it will not be displayed.
+
+brightnessicon="/usr/share/icons/Adwaita/32x32/status/display-brightness-symbolic.symbolic.png"
+
+# Here we read the notification id from a temporary file. 
+# If the file doesn't exist, we initialize it the notification to 0
+# Then we send the notification out and we reassign the notification 
+# id to the current one using tee
+
+#If the file exists, we just replace that notification id, that will 
+# then stay the same and not increment.
+
+if [ ! -f "/tmp/brightness_notification_id.dat" ]; then
+		notification_id="0"
+        		notification_id=$(notify-send-improved "Brightness Control" -i $muteicon --print-id -t 1000 "Brightness: $brightness" | tee /dev/tty)
+
+else
+		notification_id=`cat /tmp/volume_notification_id.dat`
+	                notify-send-improved "Brightness Control" -i $brightnessicon --print-id --replace=$notification_id -t 1000 "Brightness: $brightness\%"
+
+fi
+
+
+# Here we write the notification id to a file. Next time we use this 
+# script it will know if the notification has to be overwritten or not
+
+echo "${notification_id}" > /tmp/brightness_notification_id.dat

+ 113 - 0
i3-copy-scripts

@@ -0,0 +1,113 @@
+#!/bin/bash
+
+#This script copies all the scripts specified in a file to a vm of your choice. 
+#This is a qubes-os specific script.
+
+# i3-copy-scripts - Copy scripts to a vm of your choice.
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-copy-scripts
+# to make it executable.
+
+# The subroutine that copies files
+
+version=1.0
+config_file=~/.config/i3/i3-copy-scripts
+
+# This is the subroutine that performs the copying.
+# It checks that the config file exists and is not empty before
+# proceeding.
+
+copy_scripts()
+{
+line_number=1
+if [ ! -f $config_file ]; then
+        echo "The config file does not exist!"
+        exit 2
+elif [ -z `sed -n "1p" $config_file` ]; then
+        echo "The config file is empty!"
+        exit 2
+else
+
+# Here we copy all the scripts specified in the file
+# until we hit an empty line
+
+	while [ ! -z `sed -n "${line_number}p" $config_file` ]; do
+		script=`sed -n "${line_number}p" $config_file`
+
+# Here we abort if a script specified in the file does not exist
+# or cannot be located
+
+		if [ ! -f $script ]; then
+			echo "The script '$script' does not exist or I cannot find it."
+			echo "Aborting."
+			exit 2
+		fi
+
+# For security reason we don't want to export executable scripts.
+# So we make the script not executable, we pass it to the app vm
+# and we make it executable again for dom0. The change of permission must be done
+# locally, since invoking it with qvm-run within the appvm causes permission
+# problems.	
+
+		sudo chmod -x $script
+		qvm-copy-to-vm $1 $script
+		sudo chmod +x $script
+		let line_number=line_number+1
+	done
+fi
+}
+
+
+# Here we give help messages and the like
+
+if [[ $# -le 1 ]]; then
+         case $1 in
+               -v | --version)
+                        echo "$0 - Version $version"
+                        exit 0
+                        ;;
+                -h | --help)
+			echo "This script is QubesOS specific."
+			echo "It copies all the scripts specified in a file to a vm of your choice."
+			echo "All the scripts must be specified in the format"
+			echo "/path/to/script/script"
+			echo "There has to be one script per line, whithout empty lines."
+			echo "The scripts to copy have to be specified in the file ~./config/i3/i3-copy-scripts."
+                        echo "- v, --version            Display current version"
+                        echo "-h, --help                Display this message"
+                        echo "vmname                    Copies the scripts to vmname appvm"
+                        exit 0
+                        ;;
+		*)
+# Gives usage instruction if imput is empty
+			if [ -z ${1} ]; then
+                        	echo "Usage: $0 {-v, --version|-h, --help|up|toggle|down}"
+                                exit 2 
+                        fi
+# Check if the appvm exists
+			if [ ! -d /var/lib/qubes/appvms/${1} ]; then 
+				echo "The appvm '$1' does not exist."
+				echo "Usage: $0 {-v, --version|-h, --help|up|toggle|down}"
+				echo "Aborting."
+				exit 2
+			else 
+# If the appvm exists, it copies the files
+			copy_scripts $1	
+			fi
+	esac
+fi

+ 102 - 0
i3-exit

@@ -0,0 +1,102 @@
+#!/bin/bash
+
+# This is a simple program that makes shutdown easier for QubesOS.
+# May not work out of the box, you will have to specify in the script 
+# your net-vm and usb-vm names.
+
+# i3-exit - A simple QubesOS shutdown script
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-exit
+# to make it executable.
+
+version=1.0
+
+qubesnetvm=sys-net
+qubesusbvm=sys-usb
+
+# Shuts down all the virtual machines in a wise way
+vm_shutdown()
+{
+        echo "Shutting down everything"
+        qvm-shutdown --wait --all --exclude=$qubesnetvm --exclude=$qubesusbvm
+        echo "Killing sys-usb"
+        qvm-kill sys-usb
+        echo "Killing sys-net"
+        qvm-kill sys-net
+        sleep 3
+}
+
+# Checks which screensaver is installed and tries to use it
+screen_lock()
+{
+	if [ -a /bin/i3-blur ]; then
+                i3-blur
+        elif [ -a /bin/i3lock ]; then
+                i3lock
+        else
+        	echo "What screensaver are you using? I cannot find it."
+                exit 2
+	fi
+}
+
+
+if [[ "$#" -ge 2 ]]; then
+        echo "0 {-v, --version|-h, --help|lock|logout|suspend|hibernate|reboot|shutdown}"
+        exit 2
+elif [[ "$#" -eq 1 ]]; then
+case "$1" in
+        -v | --version)
+                echo "$0 - Version $version"
+                exit 0;;
+        -h | --help)
+                echo "This is a simple program that makes shutdown/hibernate/reboot etc. easier for QubesOS users having i3. May not work out of the box, you will have to specify in the script your net-vm and usb-vm names."
+                echo "- v, --version		Display current version"
+                echo "-h, --help		Display this message"
+		echo "lock			Lock the screen"
+		echo "logout			Logout current user"
+		echo "suspend			Suspend system"
+		echo "hibernate		Hibernate system"
+		echo "reboot			Reboot system"
+		echo "shutdown		Power off system"
+                exit 0
+		;;
+        lock)
+		screen_lock
+                ;;
+        logout)
+                i3-msg exit
+                ;;
+        suspend)
+                screen_lock && systemctl suspend
+                ;;
+        hibernate)
+                screen_lock && systemctl hibernate
+                ;;
+        reboot)
+                vm_shutdown; reboot
+                ;;
+        shutdown)
+                vm_shutdown; shutdown now
+                ;;
+        *)
+                echo "Usage: $0 {-v, --version|-h, --help|lock|logout|suspend|hibernate|reboot|shutdown}"
+                exit 2
+esac
+fi
+exit 0
+

+ 84 - 0
i3-layout-loader

@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# This script loads saved layouts in i3.
+# This script hightly depends on personal preferences and
+# must be edited accordingly.
+
+# i3-layout-loader - Load i3 saved layouts
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-layout-loader
+# to make it executable.
+
+version=1.0
+
+if [[ "$#" -ge 2 ]]; then
+        echo "Usage: $0 {-v, --version | -h --help}"
+        exit 2
+elif [[ $# -le 1 ]]; then
+         case $1 in
+                -v | --version)
+                        echo "$0 - Version $version"
+                        exit 0
+                        ;;
+                -h | --help)
+                        echo " This script loads saved layouts in i3. It hightly depends on personal preferences and must be edited accordingly."
+			echo "- v, --version          Display current version"
+                        echo "-h, --help              Display this message"
+                        echo "personal		Load personal layout"
+			echo "work			Load work layout"
+			echo "browsing		Load browsing layout"
+			echo "update			Load update layout"
+                        exit 0
+                        ;;
+       		 personal)
+                	i3-msg "workspace 1; append_layout ~/.config/i3/layouts/TildaFirefoxPersonal.json"
+                	qvm-run -q --tray -a personal -- 'qubes-desktop-run /usr/share/applications/firefox.desktop; qubes-desktop-run /usr/share/applications/tilda.desktop'
+            		;;
+        	work)
+                	i3-msg "workspace 3; append_layout ~/.config/i3/layouts/FileManagerTerminalEditorWorkWorkPub.json" 
+			i3-msg "workspace 2; append_layout ~/.config/i3/layouts/TexstudioWorkWorkPub.json" 
+			qvm-run -q --tray -a work-pub -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop; qubes-desktop-run /usr/share/applications/org.gnome.Terminal.desktop; qubes-desktop-run /usr/share/applications/texstudio.desktop' &
+			qvm-run -q --tray -a work -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop; qubes-desktop-run /usr/share/applications/org.gnome.Terminal.desktop; qubes-desktop-run /usr/share/applications/texstudio.desktop'
+                	;;
+        	browsing)
+        		i3-msg "workspace 5; append_layout ~/.config/i3/layouts/Browsing.json"
+                	qvm-run -q --tray -a work-pub -- 'qubes-desktop-run /usr/share/applications/firefox.desktop' &
+			qvm-run -q --tray -a untrusted -- 'qubes-desktop-run /usr/share/applications/firefox.desktop' &
+			;;
+		update)
+			i3-msg "workspace 10; append_layout ~/.config/i3/layouts/Update.json"
+                	(qvm-run -q --tray -a fedora-24-secure -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI') &
+			sleep 5
+                	(qvm-run -q --tray -a fedora-24-sys -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI') &
+                	sleep 5
+			(qvm-run -q --tray -a fedora-24-personal -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI') &
+			sleep 5
+                	(qvm-run -q --tray -a fedora-24-work -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI') &
+			sleep 5
+                	(qvm-run -q --tray -a fedora-24-untrusted -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI')&
+			sleep 10
+                	(qvm-run -q --tray -a whonix-ws -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI') &
+			sleep 5
+			(qvm-run -q --tray -a whonix-gw -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI') &
+			;;
+
+		*)
+                	echo "Usage: $0 {-v, --version|-h, --help|personal|work|browsing|update}"
+                	exit 2
+esac
+fi

+ 99 - 0
i3-screensaver-toggle

@@ -0,0 +1,99 @@
+#!/bin/bash
+
+# This is a simple program that toggles/untoggles the screensaver
+# and power management, useful to watch videos fullscreen.
+# This script relies on the script notify-send-improved.
+ 
+
+# i3-screensaver-toggle - A simple program to toggle screensaver
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-toggle-screensaver
+# to make it executable.
+
+version=1.0
+
+if [[ "$#" -ge 2 ]]; then
+        echo "Usage: $0 {-v, --version | -h --help}"
+        exit 2
+elif [[ "$#" -eq 1 ]]; then
+        case $1 in
+        -v | --version)
+                echo "$0 - Version $version"
+                exit 0;;
+        -h | --help)
+                echo "This is a simple program that toggles/untoggles the screensaver and power management, useful to watch videos fullscreen."
+                echo "- v, --version            Display current version"
+                echo "-h, --help                Display this message"
+                exit 0;;
+        *)
+                echo "Usage: $0 {-v, --version | -h, --help}"
+                exit 2;;
+        esac
+fi
+
+# Check if notify-send-improved is installed
+if [ ! -f /bin/notify-send-improved ]; then
+        echo "Notify-send-improved not present."
+        echo "Please install it."     
+	exit 2
+fi
+
+
+# Here we read the status and notification id from a temporary file. 
+# If the file doesn't exist, we initialize variables parsing xset.
+# If the file exists, we just parse it.
+
+if [ ! -f "/tmp/i3-screensaver-toggle.dat" ]; then
+        notification_id="0"
+	if  xset q | grep "DPMS is Disabled" > /dev/null; then
+		screensaver_mode="OFF"
+	else
+		screensaver_mode="ON"
+	fi
+
+else
+         screensaver_mode=`cat /tmp/i3-screensaver-toggle.dat | cut -d'.' -f 1`
+         notification_id=`cat /tmp/i3-screensaver-toggle.dat | cut -d'.' -f 2`
+fi
+
+# Here we check the previous status and notification, then proceed to change.
+if [ $screensaver_mode = "ON" ]; then
+        screensaver_mode="OFF"
+        xset s off
+        xset -dpms
+# Here we check if the notification was already used before or not, if it was, we replace it with the new one.
+        if [ $notification_id = "0" ]; then
+                notification_id=$(notify-send-improved "Screensaver Toggle" --print-id -t 1000 "Screensaver/PowerManagement off" | tee /dev/tty)
+	else
+                notify-send-improved "Screensaver Toggle" --print-id --replace=$notification_id -t 1000 "Screensaver/PowerManagement off"
+        fi
+
+else
+        screensaver_mode="ON"
+        xset s on
+        xset +dpms
+# Here we check if the notification was already used before or not, if it was, we replace it with the new one.
+        if [ $notification_id = "0" ]; then
+                notification_id=$(notify-send-improved "Screensaver Toggle" --print-id -t 1000 "Screensaver/PowerManagement on" | tee /dev/tty)
+        else
+                notify-send-improved "Screensaver Toggle" --print-id --replace=$notification_id -t 1000 "Screensaver/PowerManagement on"
+        fi
+
+fi
+
+echo "$screensaver_mode.$notification_id" > /tmp/i3-screensaver-toggle.dat

+ 130 - 0
i3-volume-toggle

@@ -0,0 +1,130 @@
+#!/bin/bash
+
+#This script increases/decreases/toggles the volume by a fixed increment specified in step.
+#This script relies on the script notify-send-improved and on pactl.
+
+# i3-volume-toggle - Increases and decreases volume.
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-volume-toggle
+# to make it executable.
+
+step=5
+
+# Check if pactl, amixer  and notify-send-improved are installed
+check_installed()
+{
+if [ ! -f /bin/notify-send-improved -a -f /bin/pactl -a -f /bin/amixer ]; then
+        echo "Notify-send-improved, amixer  and/or pactl not present."
+        echo "Please install them."     
+        exit 2
+fi
+}
+
+
+#Here we actually change the volume using pactl
+if [[ $# -le 1 ]]; then
+	 case $1 in
+               -v | --version)
+                        echo "$0 - Version $version"
+                        exit 0
+                        ;;
+                -h | --help)
+                        echo "- v, --version            Display current version"
+                        echo "-h, --help                Display this message"
+                        echo "up                        Increase volume by $step%"
+                        echo "down                      Decrease volume by $step%"
+                        echo "mute			Mute/unmute"
+			exit 0
+                        ;;
+
+		"up")
+			check_installed
+			pactl set-sink-volume  1 +$step%
+			#This produces sound feedback. Comment if you don't like it.
+			(speaker-test -t sine -f 400)& pid=$!; sleep 0.1s; kill -9 $pid
+			;;
+		"down")
+			check_installed
+			pactl set-sink-volume 1 -$step%
+			#This produces sound feedback. Comment if you don't like it.
+			(speaker-test -t sine -f 400)& pid=$!; sleep 0.1s; kill -9 $pid
+			;;
+		"toggle")
+			check_installed
+			pactl set-sink-mute 1 toggle
+                        #This produces sound feedback. Comment if you don't like it.
+                        (speaker-test -t sine -f 400)& pid=$!; sleep 0.1s; kill -9 $pid
+			;;
+		*)
+                	echo "Usage: $0 {-v, --version|-h, --help|up|toggle|down}"
+                	exit 2
+	esac
+fi
+
+# Here we get the current status of audio from alsamixer
+
+muted=`amixer get Master|tail -n1|sed -E 's/.*\[([a-z]+)\]/\1/'`
+volume=`amixer get Master|tail -n1|sed -E 's/.*\[([0-9]+)\%\].*/\1/'`
+
+# Selects the right icon for the notification
+# If icons do not exist they won't be displayed
+
+muteicon="/usr/share/icons/Adwaita/32x32/status/audio-volume-muted-symbolic.symbolic.png"
+if [ "$volume" -eq "0" ]; then
+	volumeicon=$muteicon
+elif [ "$volume" -lt "33" ]; then
+	volumeicon="/usr/share/icons/Adwaita/32x32/status/audio-volume-low-symbolic.symbolic.png"
+elif [ "$volume" -lt "66" ]; then
+	volumeicon="/usr/share/icons/Adwaita/32x32/status/audio-volume-medium-symbolic.symbolic.png"
+elif [ "$volume" -lt "120" ]; then
+	volumeicon="/usr/share/icons/Adwaita/32x32/status/audio-volume-high-symbolic.symbolic.png"
+else
+
+# The following image is obtained with this command:
+# sudo convert "/usr/share/icons/Adwaita/32x32/status/audio-volume-high-symbolic.symbolic.png" -fuzz 100% -fill red -opaque "/usr/share/icons/Adwaita/32x32/status/audio-volume-danger-symbolic.symbolic.png"
+
+	volumeicon="/usr/share/icons/Adwaita/32x32/status/audio-volume-danger-symbolic.symbolic.png"
+fi
+
+# Here we read the notification id from a temporary file. If the file doesn't exist, we initialize it the notification to 0
+# Then we send the notification out and we reassign the notification id to the current one using tee
+#
+# If the file exists, we just replace that notification id, that will then stay the same and not increment.
+
+if [ ! -f "/tmp/volume_notification_id.dat" ]; then
+		notification_id="0"
+		if [[ $muted == "off" ]]; then
+        		notification_id=$(notify-send-improved "Volume Control" -i $muteicon --print-id -t 1000 "Muted \($volume\%\)" | tee /dev/tty)
+                else
+                        notification_id=$(notify-send-improved "Volume Control" -i $volumeicon --print-id -t 1000 "Volume: $volume\%" | tee /dev/tty)
+                fi
+
+else
+		notification_id=`cat /tmp/volume_notification_id.dat`
+                if [[ $muted == "off" ]]; then
+	                notify-send-improved "Volume Control" -i $muteicon --print-id --replace=$notification_id -t 1000 "Muted \($volume\%\)"
+       		else
+                	notify-send-improved "Volume Control" -i $volumeicon --print-id --replace=$notification_id -t 1000 "Volume: $volume\%"
+        	fi
+
+fi
+
+
+# Here we write the notification id to a file. Next time we use this script it will know if the notification has to be overwritten or not
+
+echo "${notification_id}" > /tmp/volume_notification_id.dat

+ 93 - 0
i3-xrandr-toggle

@@ -0,0 +1,93 @@
+#!/bin/bash
+
+# This is a simple program that toggles an external monitor on and off
+# using xrandr.
+
+# This program won't work out of the box. You will have to rename the variables
+# $Internal and $External to suit your needs.
+
+# i3-xrandr-toggle - A simple xrandr toggle addon
+# Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+
+# You should have received a copy of the
+# GNU General Public License along with this program; if not, 
+# see <http://www.gnu.org/licenses/>
+
+# Put this file in /bin/ or in /usr/bin. Do not forget to give 
+# sudo chmod +x i3-xrandr-toggle
+# to make it executable.
+
+version=1.0
+
+if [[ "$#" -ge 2 ]]; then
+        echo "Usage: $0 {-v, --version | -h --help}"
+        exit 2
+elif [[ "$#" -eq 1 ]]; then
+        case $1 in
+        -v | --version)
+                echo "$0 - Version $version"
+                exit 0;;
+        -h | --help)
+                echo "This is a simple program that toggles an external monitor on and off using xrandr. This program won't work out of the box. You will have to rename the variables \$Internal and \$External in the script to suit your needs."
+                echo "- v, --version            Display current version"
+                echo "-h, --help                Display this message"
+                exit 0;;
+        *)
+                echo "Usage: $0 {-v, --version | -h, --help}"
+                exit 2;;
+        esac
+fi
+
+
+Internal="eDP1"
+External="DP1-3"
+
+# Grep current external monitor status. Do noting if not connected
+
+if xrandr | grep "DP1-3 connected" > /dev/null; then
+
+# Check if the program has been used before. If yes, reads previous 
+# Status from a file. If not, initialises the variables.
+
+	if [ ! -f "/tmp/monitor_mode.dat" ]; then
+		monitor_mode="ON"
+
+	else
+		monitor_mode=`cat /tmp/monitor_mode.dat`
+	fi
+
+	
+	if [ $monitor_mode = "OFF" ]; then
+		monitor_mode="ON"
+		xrandr -d :0.0 --output $External --auto
+		xrandr -d :0.0 --output $Internal --auto
+		xrandr -d :0.0 --output $External --right-of $Internal
+
+# Reloads background if using feh
+
+                if [ -a "/bin/feh" ]; then
+                ~/.fehbg
+                fi
+
+	else 
+		monitor_mode="OFF"
+		xrandr -d :0.0 --output $External --off 
+		xrandr -d :0.0 --output $Internal --auto
+	fi	
+
+# Rewrites the file for the next use.
+
+	echo "${monitor_mode}" > /tmp/monitor_mode.dat
+
+
+fi
+

+ 207 - 0
notify-send-improved

@@ -0,0 +1,207 @@
+#!/usr/bin/env bash
+
+# notify-send.sh - drop-in replacement for notify-send with more features
+# Copyright (C) 2015 Vyacheslav Levit <dev@vlevit.org>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Desktop Notifications Specification
+# https://developer.gnome.org/notification-spec/
+
+VERSION=0.1
+NOTIFY_ARGS=(--session
+             --dest org.freedesktop.Notifications
+             --object-path /org/freedesktop/Notifications)
+EXPIRE_TIME=-1
+APP_NAME="${0##*/}"
+REPLACE_ID=0
+URGENCY=1
+HINTS=()
+
+help() {
+    cat <<EOF
+Usage:
+  notify-send.sh [OPTION...] <SUMMARY> [BODY] - create a notification
+Help Options:
+  -?|--help                         Show help options
+Application Options:
+  -u, --urgency=LEVEL               Specifies the urgency level (low, normal, critical).
+  -t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.
+  -a, --app-name=APP_NAME           Specifies the app name for the icon
+  -i, --icon=ICON[,ICON...]         Specifies an icon filename or stock icon to display.
+  -c, --category=TYPE[,TYPE...]     Specifies the notification category.
+  -h, --hint=TYPE:NAME:VALUE        Specifies basic extra data to pass. Valid types are int, double, string and byte.
+  -p, --print-id                    Print the notification ID to the standard output.
+  -r, --replace=ID                  Replace existing notification.
+  -R, --replace-file=FILE           Store and load notification replace ID to/from this file.
+  -s, --close=ID                    Close notification.
+  -v, --version                     Version of the package.
+EOF
+}
+
+convert_type() {
+    case "$1" in
+        int) echo int32 ;;
+        double|string|byte) echo "$1" ;;
+        *) echo error; return 1 ;;
+    esac
+}
+
+make_hint() {
+    type=$(convert_type "$1")
+    [[ ! $? = 0 ]] && return 1
+    name="$2"
+    [[ "$type" = string ]] && value="\"$3\"" || value="$3"
+    echo "\"$name\": <$type $value>"
+}
+
+concat_hints() {
+    local result="$1"
+    shift
+    for s in "$@"; do
+        result="$result, $s"
+    done
+    echo "{$result}"
+}
+
+handle_output() {
+    if [[ -n "$STORE_ID" ]] ; then
+        sed 's/(uint32 \([0-9]\+\),)/\1/g' > $STORE_ID
+    elif [[ -z "$PRINT_ID" ]] ; then
+        cat > /dev/null
+    else
+        sed 's/(uint32 \([0-9]\+\),)/\1/g'
+    fi
+}
+
+notify () {
+    gdbus call "${NOTIFY_ARGS[@]}"  --method org.freedesktop.Notifications.Notify \
+          "$APP_NAME" "$REPLACE_ID" "$ICON" "$SUMMARY" "$BODY" \
+          [] "$(concat_hints "${HINTS[@]}")" "int32 $EXPIRE_TIME" | handle_output
+}
+
+notify_close () {
+    gdbus call "${NOTIFY_ARGS[@]}"  --method org.freedesktop.Notifications.CloseNotification "$1" >/dev/null
+}
+
+process_urgency() {
+    case "$1" in
+        low) URGENCY=0 ;;
+        normal) URGENCY=1 ;;
+        critical) URGENCY=2 ;;
+        *) echo "Unknown urgency $URGENCY specified. Known urgency levels: low, normal, critical."
+           exit 1
+           ;;
+    esac
+}
+
+process_category() {
+    IFS=, read -a categories <<< "$1"
+    for category in "${categories[@]}"; do
+        hint="$(make_hint string category "$category")"
+        HINTS=("${HINTS[@]}" "$hint")
+    done
+}
+
+process_hint() {
+    IFS=: read type name value <<< "$1"
+    if [[ -z "$name" ]] || [[ -z "$value" ]] ; then
+        echo "Invalid hint syntax specified. Use TYPE:NAME:VALUE."
+        exit 1
+    fi
+    hint="$(make_hint "$type" "$name" "$value")"
+    if [[ ! $? = 0 ]] ; then
+        echo "Invalid hint type \"$type\". Valid types are int, double, string and byte."
+        exit 1
+    fi
+    HINTS=("${HINTS[@]}" "$hint")
+}
+
+process_posargs() {
+    if [[ "$1" = -* ]] && ! [[ "$positional" = yes ]] ; then
+        echo "Unknown option $1"
+        exit 1
+    else
+        [[ -z "$SUMMARY" ]] && SUMMARY="$1" || BODY="$1"
+    fi
+}
+
+while (( $# > 0 )) ; do
+    case "$1" in
+        -\?|--help)
+            help
+            exit 0
+            ;;
+        -v|--version)
+            echo "${0##*/} $VERSION"
+            exit 0
+            ;;
+        -u|--urgency|--urgency=*)
+            [[ "$1" = --urgency=* ]] && urgency="${1#*=}" || { shift; urgency="$1"; }
+            process_urgency "$urgency"
+            ;;
+        -t|--expire-time|--expire-time=*)
+            [[ "$1" = --expire-time=* ]] && EXPIRE_TIME="${1#*=}" || { shift; EXPIRE_TIME="$1"; }
+            ;;
+        -a|--app-name|--app-name=*)
+            [[ "$1" = --app-name=* ]] && APP_NAME="${1#*=}" || { shift; APP_NAME="$1"; }
+            ;;
+        -i|--icon|--icon=*)
+            [[ "$1" = --icon=* ]] && ICON="${1#*=}" || { shift; ICON="$1"; }
+            ;;
+        -c|--category|--category=*)
+            [[ "$1" = --category=* ]] && category="${1#*=}" || { shift; category="$1"; }
+            process_category "$category"
+            ;;
+        -h|--hint|--hint=*)
+            [[ "$1" = --hint=* ]] && hint="${1#*=}" || { shift; hint="$1"; }
+            process_hint "$hint"
+            ;;
+        -p|--print-id)
+            PRINT_ID=yes
+            ;;
+        -r|--replace|--replace=*)
+            [[ "$1" = --replace=* ]] && REPLACE_ID="${1#*=}" || { shift; REPLACE_ID="$1"; }
+            ;;
+        -R|--replace-file|--replace-file=*)
+            [[ "$1" = --replace-file=* ]] && filename="${1#*=}" || { shift; filename="$1"; }
+            if [[ -s "$filename" ]]; then
+                REPLACE_ID="$(< $filename)"
+            fi
+            STORE_ID="$filename"
+            ;;
+        -s|--close|--close=*)
+            [[ "$1" = --close=* ]] && close_id="${1#*=}" || { shift; close_id="$1"; }
+            notify_close "$close_id"
+            exit $?
+            ;;
+        --)
+            positional=yes
+            ;;
+        *)
+            process_posargs "$1"
+            ;;
+    esac
+    shift
+done
+
+# urgency is always set
+HINTS=("$(make_hint byte urgency "$URGENCY")" "${HINTS[@]}")
+
+if [[ -z "$SUMMARY" ]] ; then
+    help
+    exit 1
+else
+    notify
+fi