Merge branch 'production' of github.com:Minion3665/NixFiles into production
diff --git a/1 b/1
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/1
diff --git a/README.md b/README.md
index 644ce8e..5bf8e49 100644
--- a/README.md
+++ b/README.md
@@ -34,3 +34,6 @@
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 ```
+
+The src/apps/personal/overlays/electron-screenshare.nix file is also licensed under MIT, although this time from github user gytis-ivaskevicius.
+It was originally adapted from https://github.com/gytis-ivaskevicius/nixfiles/blob/5439c8f4d7ccaeed57150846b1ed8afa0b7063ed/overlays/default.nix
diff --git a/scripts/rebuild-home.sh b/scripts/rebuild-home.sh
index ff32c4f..fd24097 100755
--- a/scripts/rebuild-home.sh
+++ b/scripts/rebuild-home.sh
@@ -9,7 +9,7 @@
     /usr/bin/env git commit -am "$changes"
 fi
 
-nix build .#homeConfigurations.${USER}.activationPackage $1
+nix build .#homeConfigurations.${USER}.activationPackage $1 || exit 1
 
 nix profile list \
   | { grep 'home-manager-path$' || test $? = 1; } \
diff --git a/src/apps/personal/overlays/electron-screenshare.nix b/src/apps/personal/overlays/electron-screenshare.nix
new file mode 100644
index 0000000..2c5b57d
--- /dev/null
+++ b/src/apps/personal/overlays/electron-screenshare.nix
@@ -0,0 +1,51 @@
+# Modified from https://github.com/gytis-ivaskevicius/nixfiles/blob/5439c8f4d7ccaeed57150846b1ed8afa0b7063ed/overlays/default.nix, which is licensed under the MIT license
+# Below is a copy of that license:
+/*
+MIT License
+
+Copyright (c) 2021 Gytis Ivaskevicius
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+# Therefore, this file is also copyable under MIT as it represents a "substantial portion" of the original code
+
+final: prev: {
+  discord = final.makeDesktopItem {
+    name = "Discord";
+    desktopName = "Discord";
+    genericName = "All-in-one cross-platform voice and text chat for gamers";
+    exec = "${final.chromium}/bin/chromium --app=\"https://discord.com/channels/@me\" --autoplay-policy=no-user-gesture-required";
+    icon = "discord";
+    type = "Application";
+    categories = "Network;InstantMessaging;";
+    terminal = "false";
+    mimeType="x-scheme-handler/discord";
+  };
+
+  element-desktop-wayland = final.makeDesktopItem {
+    name = "Element";
+    desktopName = "Element";
+    genericName = "Secure and independent communication, connected via Matrix";
+    exec = "${final.chromium}/bin/chromium --app=\"https://app.element.io/#/home\" --autoplay-policy=no-user-gesture-required";
+    icon = "element";
+    type = "Application";
+    categories = "Network;InstantMessaging;";
+    terminal = "false";
+  };
+}
diff --git a/src/apps/personal/sway.nix b/src/apps/personal/sway.nix
index 01e90e3..ef06243 100644
--- a/src/apps/personal/sway.nix
+++ b/src/apps/personal/sway.nix
@@ -84,6 +84,9 @@
                 "XF86MonBrightnessDown" = "exec lightctl down -s 200";
                 "${modifier}+Shift+s" = "exec grim -g \"$(slurp)\" - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
                 "${modifier}+g" = "sticky toggle";
+                "${modifier}+minus" = "exec ${./sway/show-menu.sh}";
+                "Print" = "exec grim - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
+                "${modifier}+Print" = "exec ${./sway/toggle-backlight.sh}";
             };
             keycodebindings = {};
             left = "h";
@@ -192,8 +195,8 @@
         avizo
         pamixer
         brightnessctl
-        light
         bc
+        jq
     ];
 
     programs.zsh.profileExtra = ''
diff --git a/src/apps/personal/sway/show-menu.sh b/src/apps/personal/sway/show-menu.sh
new file mode 100755
index 0000000..edbe00b
--- /dev/null
+++ b/src/apps/personal/sway/show-menu.sh
@@ -0,0 +1,3 @@
+export id="$(swaymsg -t get_tree | jq -r '.nodes[].nodes[] | select(.name == "__i3_scratch").floating_nodes[] | ((.id | tostring) + "\t" + (.app_id // .window_properties.class) + "\t" + .name)' | rofi -dmenu | awk '{print $1;}')"
+echo Showing $id
+swaymsg "[con_id=$id]" focus
diff --git a/src/apps/personal/sway/toggle-backlight.sh b/src/apps/personal/sway/toggle-backlight.sh
new file mode 100755
index 0000000..22ab2c1
--- /dev/null
+++ b/src/apps/personal/sway/toggle-backlight.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+read lcd < /tmp/lcd
+
+if [ "$lcd" -eq "0" ]; then
+    swaymsg "output * dpms on"
+    echo 1 > /tmp/lcd
+else
+    swaymsg "output * dpms off"
+    echo 0 > /tmp/lcd
+fi
diff --git a/src/apps/personal/zsh.nix b/src/apps/personal/zsh.nix
index 2efab5e..9b50ee6 100644
--- a/src/apps/personal/zsh.nix
+++ b/src/apps/personal/zsh.nix
@@ -32,6 +32,7 @@
             }
 
             ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243';
+            ZSH_HIGHLIGHT_STYLES[comment]='fg=248';
         '';
         enableSyntaxHighlighting = true;
         enableAutosuggestions = true;
diff --git a/src/system.nix b/src/system.nix
index 2058d3b..8f2ede5 100644
--- a/src/system.nix
+++ b/src/system.nix
@@ -10,6 +10,7 @@
     package = pkgs.nixFlakes;
     extraOptions = ''
       experimental-features = nix-command flakes
+      auto-optimise-store = true
     '';
   };
 
@@ -72,6 +73,8 @@
     ];
   };*/
 
+  programs.light.enable = true; # Needs udev rules to properly work
+
   programs.qt5ct = {
     enable = true;
   };
@@ -82,13 +85,11 @@
     portal = {
       enable = true;
       extraPortals = with pkgs; [
-        xdg-desktop-portal-wlr
-#        xdg-desktop-portal-gtk
-#        xdg-desktop-portal-kde
+        xdg-desktop-portal-gtk
+        xdg-desktop-portal-kde
       ];
-#      gtkUsePortal = true;
-      wlr.enable = true;
-      
+      gtkUsePortal = true;
+      wlr.enable = true;     
     };
   };