Browse Source

Lots of stuff updated. acpid events and actions added.

Fabrizio Romano Genovese 7 years ago
parent
commit
cbb8ba2c52

+ 97 - 0
acpid actions/camera.sh

@@ -0,0 +1,97 @@
+#!/bin/bash
+
+# This script attaches webcam and audio to a specific AppVm.
+# It is specific for QubesOS.
+# 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 /etc/acpi/actions. Do not forget to give 
+# sudo chmod +x camera.sh
+# to make it executable.
+
+# ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA sudo SPECIFYING DISPLAY
+# BECAUSE OF QUBESOS WEIRDNESS. 
+# IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER.
+
+camera="sys-usb:2-1.6"
+user="Nigredo"
+AppVM="personal"
+
+# Checks if a VM exists
+checker()
+{
+vmstate=`sudo -u Nigredo -H sh -c "DISPLAY=:0 qvm-check  $1 | grep \"not\""`
+if [ -z "$vmstate" ]; then
+        echo "VM $1 exists."
+else
+        echo "The VM $1 does not exist. aborting"
+        exit 2
+fi
+}
+
+# Attach ($2=true) or detach ($1=false) microphone to AppVM $1
+# Thanks to Rusty Bird for the correct dbus command.
+microphone()
+{
+checker $1
+sudo -u Nigredo -H sh -c "DISPLAY=:0 dbus-send --type=method_call --dest=org.QubesOS.Audio.\"$1\" \
+        /org/qubesos/audio org.freedesktop.DBus.Properties.Set \
+        string:org.QubesOS.Audio string:RecAllowed variant:boolean:\"$2\""
+}
+
+
+# Check if the script has been used before using a tmp file. If not, creates it
+# And initializes notification counter. If yes, parses the content of the tmp file
+# Then attaches/detaches camera using qvm-usb and microphone using microphone subroutine.
+# Then displays the relevant notifications and updates the variables to be written in the tmp file.
+if [ ! -f "/tmp/camera_notification_id.dat" ]; then
+        notification_id="0"
+
+        sudo -u Nigredo -H sh -c "qvm-usb -a $AppVM $camera"
+        microphone $AppVM true
+
+        notification_id=$(sudo -u $user -H sh -c "DISPLAY:=0 notify-send-improved \"Camera Control\" --print-id -t 1000 \"Camera and microphone connected to $AppVM\" | tee /dev/tty")
+
+        camera_id="$notification_id.ON"
+
+else
+        camera_id=`cat /tmp/camera_notification_id.dat`
+        notification_id=`echo $camera_id | cut -f1 -d"."`
+        camera_status=`echo $camera_id | cut -f2 -d"."`
+
+        if [ $camera_status = "ON" ]; then
+                sudo -u Nigredo -H sh -c "qvm-usb -d $camera"
+                microphone $AppVM false
+
+                notification_id=$(sudo -u $user -H sh -c "DISPLAY=:0 notify-send-improved \"Camera Control\" --print-id -t 1000 \"Camera and microphone disconnected from $AppVM\" | tee /dev/tty")
+
+                camera_id="$notification_id.OFF"
+
+
+        else
+               sudo -u Nigredo -H sh -c "qvm-usb -a $AppVM $camera"
+                microphone $AppVM true
+
+                notification_id=$(sudo -u $user -H sh -c "DISPLAY=:0 notify-send-improved \"Camera Control\" --print-id -t 1000 \"Camera and microphone connected to $AppVM\" | tee /dev/tty")
+
+                camera_id="$notification_id.ON"
+
+        fi
+
+fi
+
+# Update the tmp file
+        echo "${camera_id}" > /tmp/camera_notification_id.dat
+                                                                  

+ 41 - 0
acpid actions/lid.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# This script invokes the screensaver when the lid is closed,
+# then puts the pc to sleep.
+
+# 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 /etc/acpi/actions/. Do not forget to give 
+# sudo chmod +x lid.sh 
+# to make it executable.
+
+# ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA su -c BECAUSE OF QUBESOS WEIRDNESS. 
+# IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER.
+
+# Modify the username to suit yours!
+
+user=Nigredo
+screensaver=i3-blur
+
+# Grepping the lid status
+state=`grep open /proc/acpi/button/lid/*/state`
+
+# Checks if the scring is empty. If it is, executes the if
+if [ -z $state ]; then 
+	sudo -u $user -H sh -c "DISPLAY=:0 $screensaver"
+	systemctl suspend
+fi
+

+ 33 - 0
acpid actions/power.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# This script invokes the system mode in the i3 config file. Useful with acpid if
+# Power button is pressed.
+
+# 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 /etc/acpi/actions/. Do not forget to give 
+# sudo chmod +x power.sh 
+# to make it executable.
+
+# ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA sudo SPECIFYING DISPLAY
+#  BECAUSE OF QUBESOS WEIRDNESS. 
+# IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER.
+
+# Grep the system variable in the i3 config file, that defines the correspondent mode.
+sysname=`sudo -u Nigredo -H sh -c 'DISPLAY=:0 sudo grep "set \\$system" /home/Nigredo/.config/i3/config | tail -c +13'`
+ 
+# Invoke the mode in i3
+ sudo -u Nigredo -H sh -c "DISPLAY=:0 i3-msg mode '$sysname'"

+ 34 - 0
acpid actions/sleep.sh

@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# This script invokes the screensaver and puts the pc to sleep.
+
+# 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 /etc/acpi/actions/. Do not forget to give 
+# sudo chmod +x sleep.sh 
+# to make it executable.
+
+# ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA su -c BECAUSE OF QUBESOS WEIRDNESS. 
+# IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER.
+
+# Modify the username to suit yours!
+
+user=Nigredo
+screensaver=i3-blur
+ 
+sudo -u $user -H sh -c "DISPLAY=:0 $screensaver"
+ systemctl suspend
+

+ 6 - 0
acpid events/camera

@@ -0,0 +1,6 @@
+# acpid event to connect camera and microphone to a vm if the microphone
+# button is pressed.
+# Put this in /sudo/acpi/events
+
+event=button/f20
+action=/etc/acpi/actions/camera.sh

+ 336 - 0
acpid events/config

@@ -0,0 +1,336 @@
+# This file has been auto-generated by i3-config-wizard(1).
+# It will not be overwritten, so edit it as you like.
+#
+# Should you change your keyboard layout some time, delete
+# this file and re-run i3-config-wizard(1).
+#
+
+# i3 config file (v4)
+#
+# Please see http://i3wm.org/docs/userguide.html for a complete reference!
+
+set $mod Mod1
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below.
+# This font is widely installed, provides lots of unicode glyphs, right-to-left
+# text rendering and scalability on retina/hidpi displays (thanks to pango).
+font pango:DejaVu Sans Mono 8
+# Before i3 v4.8, we used to recommend this one as the default:
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+# The font above is very space-efficient, that is, it looks good, sharp and
+# clear in small sizes. However, its unicode glyph coverage is limited, the old
+# X core fonts rendering does not support right-to-left and this being a bitmap
+# font, it doesn’t scale on retina/hidpi displays.
+
+# Use Mouse+$mod to drag floating windows to their wanted position
+floating_modifier $mod
+
+# start a terminal in the domain of the currently active window
+bindsym $mod+Return exec qubes-i3-sensible-terminal
+
+# kill focused window
+bindsym $mod+Shift+q kill
+
+# start dmenu (a program launcher)
+bindsym $mod+d exec --no-startup-id i3-dmenu-desktop --dmenu="dmenu -nb #d2d2d2 -nf #000000 -sb #63a0ff"
+
+# change focus
+#bindsym $mod+j focus left
+#bindsym $mod+k focus down
+#bindsym $mod+l focus up
+#bindsym $mod+semicolon focus right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Left focus left
+bindsym $mod+Down focus down
+bindsym $mod+Up focus up
+bindsym $mod+Right focus right
+
+# move focused window
+#bindsym $mod+Shift+j move left
+#bindsym $mod+Shift+k move down
+#bindsym $mod+Shift+l move up
+#bindsym $mod+Shift+semicolon move right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Shift+Left move left
+bindsym $mod+Shift+Down move down
+bindsym $mod+Shift+Up move up
+bindsym $mod+Shift+Right move right
+
+# split in horizontal orientation
+bindsym $mod+h split h
+
+# split in vertical orientation
+bindsym $mod+v split v
+
+# enter fullscreen mode for the focused container
+bindsym $mod+f fullscreen
+
+# change container layout (stacked, tabbed, toggle split)
+bindsym $mod+s layout stacking
+bindsym $mod+w layout tabbed
+bindsym $mod+e layout toggle split
+
+# toggle tiling / floating
+bindsym $mod+Shift+space floating toggle
+
+# change focus between tiling / floating windows
+bindsym $mod+space focus mode_toggle
+
+# focus the parent container
+bindsym $mod+a focus parent
+
+# focus the child container
+#bindsym $mod+d focus child
+
+# cycle through active workspaces
+bindsym $mod+Tab workspace next
+# switch to workspace
+bindsym $mod+1 workspace 1
+bindsym $mod+2 workspace 2
+bindsym $mod+3 workspace 3
+bindsym $mod+4 workspace 4
+bindsym $mod+5 workspace 5
+bindsym $mod+6 workspace 6
+bindsym $mod+7 workspace 7
+bindsym $mod+8 workspace 8
+bindsym $mod+9 workspace 9
+bindsym $mod+0 workspace 10
+
+# move focused container to workspace
+bindsym $mod+Shift+1 move container to workspace 1
+bindsym $mod+Shift+2 move container to workspace 2
+bindsym $mod+Shift+3 move container to workspace 3
+bindsym $mod+Shift+4 move container to workspace 4
+bindsym $mod+Shift+5 move container to workspace 5
+bindsym $mod+Shift+6 move container to workspace 6
+bindsym $mod+Shift+7 move container to workspace 7
+bindsym $mod+Shift+8 move container to workspace 8
+bindsym $mod+Shift+9 move container to workspace 9
+bindsym $mod+Shift+0 move container to workspace 10
+
+# reload the configuration file
+bindsym $mod+Shift+c reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindsym $mod+Shift+r restart
+# exit i3 (logs you out of your X session)
+bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
+
+# resize window (you can also use the mouse for that)
+mode "resize" {
+        # These bindings trigger as soon as you enter the resize mode
+
+        # Pressing left will shrink the window’s width.
+        # Pressing right will grow the window’s width.
+        # Pressing up will shrink the window’s height.
+        # Pressing down will grow the window’s height.    
+   	# bindsym j resize shrink width 10 px or 10 ppt
+        # bindsym k resize grow height 10 px or 10 ppt
+        # bindsym l resize shrink height 10 px or 10 ppt
+        # bindsym semicolon resize grow width 10 px or 10 ppt
+
+        # same bindings, but for the arrow keys
+        bindsym Left resize shrink width 10 px or 10 ppt
+        bindsym Down resize grow height 10 px or 10 ppt
+        bindsym Up resize shrink height 10 px or 10 ppt
+        bindsym Right resize grow width 10 px or 10 ppt
+
+        # back to normal: Enter or Escape
+        bindsym Return mode "default"
+        bindsym Escape mode "default"
+}
+
+bindsym $mod+r mode "resize"
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+        status_command qubes-i3status
+        colors {
+            background #d2d2d2
+            statusline #00000
+
+            #class               #border #backgr #text
+            focused_workspace    #4c7899 #63a0ff #000000
+            active_workspace     #333333 #5f676a #ffffff
+            inactive_workspace   #222222 #333333 #888888
+            urgent_workspace     #BD2727 #E79E27 #000000
+        }
+}
+
+# Use a screen locker. Top right corner will inhibit screensaver.
+# Relies on the script i3-lock
+exec --no-startup-id "xautolock -time 3 -locker 'i3-blur' -notify 30 -notifier \"notify-send -t 2000 'Locking screen in 30 seconds'\""
+
+# Make sure all xdg autostart entries are started, this is (among other things)
+# necessary to make sure transient vm's come up
+exec --no-startup-id qubes-i3-xdg-autostart
+
+###################################################
+#### MY OWN COMMANDS ####
+###################################################
+
+## LOOK AND FEEL ##
+
+# Bind workspaces to the right display. Odd workspaces are on the laptop one, even workspaces on the external display.
+# Use xrandr --display :0| grep "connected" to get output display names.
+workspace 1 output eDP1
+workspace 3 output eDP1
+workspace 5 output eDP1
+workspace 7 output eDP1
+workspace 9 output eDP1
+
+workspace 2 output DP1-3
+workspace 4 output DP1-3
+workspace 6 output DP1-3
+workspace 8 output DP1-3
+workspace 10 output DP1-3
+
+# Screen toggle
+# Relies on the script i3-xrandr-toggle
+bindsym $mod+F8 exec i3-xrandr-toggle
+
+# Disable screensaver and power management
+# Relies on the script i3-screensaver-toggle
+bindsym $mod+F7 exec i3-screensaver-toggle
+
+# Set background
+# Relies on the package feh
+exec ~/.fehbg
+
+# Lock screen
+# Relies on the script i3-lock
+bindsym $mod+l exec i3-blur
+
+# Volume control
+# Relies on the script i3-volume-toggle
+bindsym XF86AudioLowerVolume exec i3-volume-toggle down
+bindsym XF86AudioRaiseVolume exec i3-volume-toggle up
+bindsym XF86AudioMute exec i3-volume-toggle toggle
+
+# Brightness control
+# Relies on the script i3-brightness-toggle
+bindsym XF86MonBrightnessDown exec i3-brightness-toggle down
+bindsym XF86MonBrightnessUp exec i3-brightness-toggle up
+
+# Assignments
+# Nothing here, add assignments if you want.
+
+## VM-RELATED ENVIRONMENTS ##
+# System (shutdown,restart, etc)
+# Relies on the script i3-exit
+bindcode 135 exec qubes-manager
+
+set $system System: [q] Qubes-manager [l] lock [e] logout [s] suspend [h] hibernate [r] reboot [Shift+s] shutdown
+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 i3-exit reboot; mode "default"
+	bindsym Shift+s exec i3-exit shutdown; mode "default"
+	bindsym Escape mode "default"
+        bindsym Return mode "default"
+}
+
+# Dom0
+set $dom0 Dom0: [n] File Manager [t] Terminal [q] Qubes Manager
+bindsym $mod+u mode "$dom0"
+mode "$dom0" {
+	#bindsym n exec qvm-run -q --tray -a personal -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop'; mode "default" 
+	bindsym n exec dolphin; mode "default"
+	bindsym t exec konsole; mode "default"
+	bindsym q exec qubes-manager; mode "default"
+	bindsym Escape mode "default"
+	bindsym Return mode "default"
+}
+
+# Personal
+set $personal Personal: [n] File Manager [f] Firefox [t] Terminal [q] Shutdown
+bindsym $mod+bracketleft mode "$personal"
+mode "$personal" {
+	bindsym n exec qvm-run -q --tray -a personal -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop'; mode "default" 
+	bindsym f exec qvm-run -q --tray -a personal -- 'qubes-desktop-run /usr/share/applications/firefox.desktop'; mode "default"
+	bindsym t exec qvm-run -q --tray -a personal -- 'qubes-desktop-run /usr/share/applications/org.gnome.Terminal.desktop'; mode "default"
+	bindsym q exec qvm-shutdown personal; mode "default"
+	bindsym Escape mode "default"
+	bindsym Return mode "default"
+}
+
+# Work
+set $work Work: [n] File Manager [l] TeXstudio [t] Terminal [q] Shutdown
+bindsym $mod+apostrophe mode "$work"
+mode "$work" {
+        bindsym n exec qvm-run -q --tray -a work -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop'; mode "default"
+       #bindsym f exec qvm-run -q --tray -a work -- 'qubes-desktop-run /usr/share/applications/firefox.desktop'; mode "default"
+        bindsym t exec qvm-run -q --tray -a work -- 'qubes-desktop-run /usr/share/applications/org.gnome.Terminal.desktop'; mode "default"
+        bindsym l exec qvm-run -q --tray -a work -- 'qubes-desktop-run /usr/share/applications/texstudio.desktop'; mode "default"
+        bindsym q exec qvm-shutdown work; mode "default"
+        bindsym Escape mode "default"
+        bindsym Return mode "default"
+}
+
+
+# WorkPub
+set $work-pub Work-Pub: [n] File Manager [f] Firefox [l] TeXstudio [m] Mendeley [t] Terminal [q] Shutdown
+bindsym $mod+bracketright mode "$work-pub"
+mode "$work-pub" {
+	bindsym n exec qvm-run -q --tray -a work-pub -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop'; mode "default"
+	bindsym f exec qvm-run -q --tray -a work-pub -- 'qubes-desktop-run /usr/share/applications/firefox.desktop'; mode "default"
+	bindsym t exec qvm-run -q --tray -a work-pub -- 'qubes-desktop-run /usr/share/applications/org.gnome.Terminal.desktop'; mode "default"
+	bindsym l exec qvm-run -q --tray -a work-pub -- 'qubes-desktop-run /usr/share/applications/texstudio.desktop'; mode "default"
+	bindsym q exec qvm-shutdown work-pub; mode "default"
+	bindsym m exec qvm-run -q --tray -a work-pub -- '~/Mendeley/bin/mendeleydesktop'; mode "default"
+	bindsym Escape mode "default"
+	bindsym Return mode "default"
+}
+
+
+# Untrusted
+set $untrusted Untrusted: [n] File Manager [f] Firefox [k] Kodi Media Center [t] Terminal [q] Shutdown
+bindsym $mod+numbersign mode "$untrusted"
+mode "$untrusted" {
+	bindsym n exec qvm-run -q --tray -a untrusted -- 'qubes-desktop-run /usr/share/applications/org.gnome.Nautilus.desktop'; mode "default"
+	bindsym f exec qvm-run -q --tray -a untrusted -- 'qubes-desktop-run /usr/share/applications/firefox.desktop'; mode "default"
+	bindsym t exec qvm-run -q --tray -a untrusted -- 'qubes-desktop-run /usr/share/applications/org.gnome.Terminal.desktop'; mode "default"
+	bindsym c exec qvm-run -q --tray -a untrusted -- 'qubes-desktop-run /usr/share/applications/google-chrome.desktop'; mode "default"
+	bindsym k exec qvm-run -q --tray -a untrusted -- 'qubes-desktop-run /usr/share/applications/kodi.desktop'; mode "default"
+	bindsym q exec qvm-shutdown untrusted; mode "default"
+	bindsym Escape mode "default"
+	bindsym Return mode "default"
+}
+
+# Quit
+set $quit Quit Menu: [p] Personal [w] Work-Pub [W] Work [u] Untrusted [s] Shopping [b] Banking [v] Vault [a] Anon-Whonix [S] Sys-Whonix
+bindsym $mod+q mode "$quit"
+mode "$quit" {
+        bindsym p exec qvm-shutdown personal; mode "default"
+        bindsym w exec qvm-shutdown work-pub; mode "default"
+        bindsym Shift+w  exec qvm-shutdown work; mode "default"
+        bindsym u exec qvm-shutdown untrusted; mode "default"
+        bindsym s exec qvm-shutdown shopping; mode "default"
+        bindsym b exec qvm-shutdown banking; mode "default"
+        bindsym v exec qvm-shutdown vault; mode "default"
+        bindsym a exec qvm-shutdown anon-whonix; mode "default"
+        bindsym Shift+s exec qvm-shutdown sys-whonix; mode "default"
+
+	bindsym Escape mode "default"
+	bindsym Return mode "default"
+}
+
+########################
+## SAVED ENVIRONMENTS ##
+########################
+# The following mode relies on the script i3-layout-loader
+set $layout Load Layouts: [p] Personal [w] Work [b] Internet Browsing [u] Update
+bindsym $mod+m mode "$layout"
+mode "$layout" {
+	bindsym p exec i3-layout-loader personal; mode "default"
+	bindsym w exec i3-layout-loader work; mode "default"
+	bindsym b exec i3-layout-loader browsing; mode "default"
+	bindsym u exec i3-layout-loader update; mode "default"
+	bindsym Escape mode "default"
+	bindsym Return mode "default"
+}

+ 245 - 0
acpid events/dunstrc

@@ -0,0 +1,245 @@
+[global]
+    font = Monospace 8
+    
+    # Allow a small subset of html markup:
+    #   <b>bold</b>
+    #   <i>italic</i>
+    #   <s>strikethrough</s>
+    #   <u>underline</u>
+    # 
+    # For a complete reference see
+    # <http://developer.gnome.org/pango/stable/PangoMarkupFormat.html>.
+    # If markup is not allowed, those tags will be stripped out of the
+    # message.
+    allow_markup = yes
+    
+    # The format of the message.  Possible variables are:
+    #   %a  appname
+    #   %s  summary
+    #   %b  body
+    #   %i  iconname (including its path)
+    #   %I  iconname (without its path)
+    #   %p  progress value if set ([  0%] to [100%]) or nothing
+    # Markup is allowed
+    format = "<b>%s</b>\n%b"
+    
+    # Sort messages by urgency.
+    sort = yes
+    
+    # Show how many messages are currently hidden (because of geometry).
+    indicate_hidden = no
+    
+    # Alignment of message text.
+    # Possible values are "left", "center" and "right".
+    alignment = left
+    
+    # The frequency with wich text that is longer than the notification
+    # window allows bounces back and forth.
+    # This option conflicts with "word_wrap".
+    # Set to 0 to disable.
+    bounce_freq = 0
+    
+    # Show age of message if message is older than show_age_threshold
+    # seconds.
+    # Set to -1 to disable.
+    show_age_threshold = 60
+    
+    # Split notifications into multiple lines if they don't fit into
+    # geometry.
+    word_wrap = yes
+    
+    # Ignore newlines '\n' in notifications.
+    ignore_newline = no
+    
+    
+    # The geometry of the window:
+    #   [{width}]x{height}[+/-{x}+/-{y}]
+    # The geometry of the message window.
+    # The height is measured in number of notifications everything else
+    # in pixels.  If the width is omitted but the height is given
+    # ("-geometry x2"), the message window expands over the whole screen
+    # (dmenu-like).  If width is 0, the window expands to the longest
+    # message displayed.  A positive x is measured from the left, a
+    # negative from the right side of the screen.  Y is measured from
+    # the top and down respectevly.
+    # The width can be negative.  In this case the actual width is the
+    # screen width minus the width defined in within the geometry option.
+    geometry = "300x5-30+20"
+    
+    # Shrink window if it's smaller than the width.  Will be ignored if
+    # width is 0.
+    shrink = no
+    
+    # The transparency of the window.  Range: [0; 100].
+    # This option will only work if a compositing windowmanager is
+    # present (e.g. xcompmgr, compiz, etc.).
+    transparency = 90
+    
+    # Don't remove messages, if the user is idle (no mouse or keyboard input)
+    # for longer than idle_threshold seconds.
+    # Set to 0 to disable.
+    idle_threshold = 120
+    
+    # Which monitor should the notifications be displayed on.
+    monitor = 0
+    
+    # Display notification on focused monitor.  Possible modes are:
+    #   mouse: follow mouse pointer
+    #   keyboard: follow window with keyboard focus
+    #   none: don't follow anything
+    # 
+    # "keyboard" needs a windowmanager that exports the
+    # _NET_ACTIVE_WINDOW property.
+    # This should be the case for almost all modern windowmanagers.
+    # 
+    # If this option is set to mouse or keyboard, the monitor option
+    # will be ignored.
+    follow = mouse
+    
+    # Should a notification popped up from history be sticky or timeout
+    # as if it would normally do.
+    sticky_history = yes
+    
+    # Maximum amount of notifications kept in history
+    history_length = 20
+    
+    # Display indicators for URLs (U) and actions (A).
+    show_indicators = yes
+    
+    # The height of a single line.  If the height is smaller than the
+    # font height, it will get raised to the font height.
+    # This adds empty space above and under the text.
+    line_height = 0
+    
+    # Draw a line of "separatpr_height" pixel height between two
+    # notifications.
+    # Set to 0 to disable.
+    separator_height = 2
+    
+    # Padding between text and separator.
+    padding = 8
+    
+    # Horizontal padding.
+    horizontal_padding = 8
+    
+    # Define a color for the separator.
+    # possible values are:
+    #  * auto: dunst tries to find a color fitting to the background;
+    #  * foreground: use the same color as the foreground;
+    #  * frame: use the same color as the frame;
+    #  * anything else will be interpreted as a X color.
+    separator_color = frame
+    
+    # Print a notification on startup.
+    # This is mainly for error detection, since dbus (re-)starts dunst
+    # automatically after a crash.
+    startup_notification = false
+    
+    # dmenu path.
+    dmenu = /usr/bin/dmenu -p dunst:
+    
+    # Browser for opening urls in context menu.
+    browser = /usr/bin/firefox -new-tab
+
+    # Align icons left/right/off
+    icon_position = left
+
+    # Paths to default icons.
+    icon_folders = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/
+
+[frame]
+    width = 1
+    color = "#383838"
+
+[shortcuts]
+
+    # Shortcuts are specified as [modifier+][modifier+]...key
+    # Available modifiers are "ctrl", "mod1" (the alt-key), "mod2",
+    # "mod3" and "mod4" (windows-key).
+    # Xev might be helpful to find names for keys.
+    
+    # Close notification.
+    #close = ctrl+delete
+    
+    # Close all notifications.
+    #close_all = ctrl+shift+delete
+    
+    # Redisplay last message(s).
+    # On the US keyboard layout "grave" is normally above TAB and left
+    # of "1".
+    history = ctrl+space
+    
+    # Context menu.
+    close= ctrl+shift+period
+
+[urgency_low]
+    # IMPORTANT: colors have to be defined in quotation marks.
+    # Otherwise the "#" and following would be interpreted as a comment.
+    background = "#181818"
+    foreground = "#E3C7AF"
+    timeout = 10
+
+[urgency_normal]
+    background = "#181818"
+    foreground = "#546470"
+    timeout = 10
+
+[urgency_critical]
+    background = "#181818"
+    foreground = "#DB7272"
+    timeout = 0
+
+
+# Every section that isn't one of the above is interpreted as a rules to
+# override settings for certain messages.
+# Messages can be matched by "appname", "summary", "body", "icon", "category",
+# "msg_urgency" and you can override the "timeout", "urgency", "foreground",
+# "background", "new_icon" and "format".
+# Shell-like globbing will get expanded.
+#
+# SCRIPTING
+# You can specify a script that gets run when the rule matches by
+# setting the "script" option.
+# The script will be called as follows:
+#   script appname summary body icon urgency
+# where urgency can be "LOW", "NORMAL" or "CRITICAL".
+# 
+# NOTE: if you don't want a notification to be displayed, set the format
+# to "".
+# NOTE: It might be helpful to run dunst -print in a terminal in order
+# to find fitting options for rules.
+
+#[espeak]
+#    summary = "*"
+#    script = dunst_espeak.sh
+
+#[script-test]
+#    summary = "*script*"
+#    script = dunst_test.sh
+
+#[ignore]
+#    # This notification will not be displayed
+#    summary = "foobar"
+#    format = ""
+
+#[signed_on]
+#    appname = Pidgin
+#    summary = "*signed on*"
+#    urgency = low
+#
+#[signed_off]
+#    appname = Pidgin
+#    summary = *signed off*
+#    urgency = low
+#
+#[says]
+#    appname = Pidgin
+#    summary = *says*
+#    urgency = critical
+#
+#[twitter]
+#    appname = Pidgin
+#    summary = *twitter.com*
+#    urgency = normal
+#
+# vim: ft=cfg

+ 5 - 0
acpid events/lid

@@ -0,0 +1,5 @@
+# acpid event to lock and suspend pc if lid is closed.
+# Put this in /etc/acpi/events
+
+event=button/lid
+action=/etc/acpi/actions/lid.sh

+ 5 - 0
acpid events/powerconf

@@ -0,0 +1,5 @@
+# acpi event to invoke i3 system menu if powerbutton is pressed.
+# Put this in /etc/acpi/events
+
+event=power
+action=/etc/acpi/actions/power.sh

+ 5 - 0
acpid events/sleep

@@ -0,0 +1,5 @@
+# acpid event to put the pc to sleep if sleep button is pressed.
+# Put this in /etc/acpi/events
+
+event=button/sleep SBTN
+action=/etc/acpi/actions/sleep.sh

+ 34 - 17
i3-copy-scripts

@@ -32,6 +32,18 @@ configs_file=$HOME/.config/i3/i3-copy-configs
 # It checks that the config file exists and is not empty before
 # proceeding.
 
+checker()
+{
+vmstate=`qvm-check  $1 | grep "not"`
+if [ -z "$vmstate" ]; then
+        echo "VM $1 exists. Proceeding."
+else   
+        echo "The VM $1 does not exist. Aborting."
+	echo "Usage: $0 {-v, --version|-h, --help| vmname}"
+	exit 2
+fi
+}
+
 copy_scripts()
 {
 if [ ! -f $scripts_file ]; then
@@ -42,6 +54,7 @@ elif [ -z `sed -n "1p" $scripts_file` ]; then
         exit 2
 else
 
+
 # Here we copy all the scripts specified in the file
 # until we hit an empty line
 	line_number=1
@@ -108,16 +121,26 @@ if [[ $# -le 1 ]]; then
                         exit 0
                         ;;
                 -h | --help)
-			echo "This script is QubesOS specific."
-			echo "It copies all the scripts/configuration files specified in a file to a vm of your choice."
-			echo "All the inputs must have the format"
-			echo "/path/to/script/script"
-			echo "There has to be one input per line, whithout empty lines."
-			echo "The scripts to copy have to be specified in the file ~./config/i3/i3-copy-scripts."
-			echo "The configuration files to copy have to be specified in the file ~./config/i3/i3-copy-configs."
-                        echo "- v, --version            Display current version"
-                        echo "-h, --help                Display this message"
-                        echo "vmname                    Copies the scripts to vmname appvm"
+			echo "This script is QubesOS specific.
+Usage: $0 {-v, --version|-h, --help| vmname}.
+
+It copies all the scripts/configuration files specified in a file to a vm of your choice. All the inputs must have the format
+
+/path/to/script/script
+
+There has to be one input per line, whithout empty lines.
+The scripts to copy have to be specified in the file 
+
+~./config/i3/i3-copy-scripts.
+
+The configuration files to copy have to be specified in the file ~./config/i3/i3-copy-configs.
+
+
+
+- v, --version            Display current version
+-h, --help                Display this message
+vmname                    Copies the scripts to vmname appvm"
+
                         exit 0
                         ;;
 		*)
@@ -128,15 +151,9 @@ if [[ $# -le 1 ]]; then
                         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 
+			checker $1
 
 # If the appvm exists, it copies the files
 			copy_scripts $1	
-			fi
 	esac
 fi

+ 89 - 22
i3-layout-loader

@@ -23,8 +23,70 @@
 # 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=2.0
+
+# This checks if the vm $0 exists. If it does, starts the update.
+# Otherwise aborts.
+
+netvmlist=( "sys-whonix" )
+vmlist=( "fedora-24-secure" "fedora-24-sys" "fedora-24-personal" "fedora-24-work" "fedora-24-untrusted" "whonix-ws" "whonix-gw" )
+
+# Display help message
+display_help()
+{
+echo " This script loads saved layouts in i3. It hightly depends on personal preferences and must be edited accordingly.
+
+- v, --version		Display current version
+-h, --help		Display this message
+personal		Load personal layout
+work			Load work layout
+browsing		Load browsing layout
+update			Load update layout"
+
+exit 0
+}
+
+# Check if a vm exists
+checker()
+{
+vmstate=`qvm-check  $1 | grep "not"`
+if [ -z "$vmstate" ]; then
+        echo "VM $1 exists."
+else
+        echo "The VM $1 does not exist. aborting"
+        exit 2
+fi
+}
+
+# Starts the update in a VM
+starter()               
+{                
+	qvm-run -q --tray -a $1 -- 'bash /etc/qubes-rpc/qubes.InstallUpdatesGUI' &
+	echo "Starting $1..."
+}
+
+# This waits until:
+# $1 = 0: The vm $0 is running
+# $1 = 1; The vm $0 is stopped
+delayer()
+{
+vmstate=`qvm-check --running $1 | grep "not"`
+if [ "$2" = 0 ]; then
+        while [ ! -z "$vmstate" ]; do
+		echo "Waiting for VM $1 to finish startup..."
+                sleep 1
+                vmstate=`qvm-check --running $1 | grep "not"`
+        done
+elif [ "$2" = 1 ]; then
+        while [ -z "$vmstate" ]; do
+		echo "Waiting for VM $1 to close..."
+                sleep 5
+        	vmstate=`qvm-check --running $1 | grep "not"`
+	done
+fi
+sleep 2
+}
 
-version=1.0
 
 if [[ "$#" -ge 2 ]]; then
         echo "Usage: $0 {-v, --version | -h --help}"
@@ -36,14 +98,7 @@ elif [[ $# -le 1 ]]; then
                         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
+                        display_help
                         ;;
        		 personal)
                 	i3-msg "workspace 1; append_layout ~/.config/i3/layouts/TildaFirefoxPersonal.json"
@@ -62,19 +117,31 @@ elif [[ $# -le 1 ]]; then
 			;;
 		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') &
+      	
+			for i in ${netvmlist[*]};
+                        do
+				checker $i
+                        	qvm-start -q $i & 
+                        	delayer $i 0
+                        done
+
+			for i in ${vmlist[*]};
+			do
+				checker $i
+				starter $i
+				delayer $i 0
+			done
+
+			for i in ${vmlist[*]};
+			do
+				delayer $i 1
+			done
+
+			for i in ${netvmlist[*]};
+                        do
+                        	echo "Shutting down VM $i..."
+				qvm-shutdown -q $i
+                        done
 			;;
 
 		*)

+ 34 - 0
logind.conf

@@ -0,0 +1,34 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+#
+# Entries in this file show the compile time defaults.
+# You can change settings by editing this file.
+# Defaults can be restored by simply deleting this file.
+#
+# See logind.conf(5) for details.
+
+[Login]
+#NAutoVTs=6
+#ReserveVT=6
+#KillUserProcesses=no
+#KillOnlyUsers=
+#KillExcludeUsers=root
+#InhibitDelayMaxSec=5
+HandlePowerKey=ignore
+HandleSuspendKey=ignore
+#HandleHibernateKey=hibernate
+HandleLidSwitch=ignore
+#HandleLidSwitchDocked=ignore
+#PowerKeyIgnoreInhibited=no
+#SuspendKeyIgnoreInhibited=no
+#HibernateKeyIgnoreInhibited=no
+#LidSwitchIgnoreInhibited=yes
+#HoldoffTimeoutSec=30s
+#IdleAction=ignore
+#IdleActionSec=30min
+#RuntimeDirectorySize=10%
+#RemoveIPC=yes