2024-07-19 13:59:48 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.ar.home;
|
|
|
|
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
|
|
|
|
virtKeyboard = lib.getExe' pkgs.squeekboard "squeekboard";
|
|
|
|
in {
|
|
|
|
clamshell = pkgs.writeShellScript "hyprland-clamshell" ''
|
2024-08-02 20:56:49 -04:00
|
|
|
EDP_STATUS=$(${hyprctl} monitors all | grep -A 15 "Monitor eDP-1" | grep "disabled:")
|
2024-08-04 19:31:25 -04:00
|
|
|
|
2024-07-19 13:59:48 -04:00
|
|
|
if [ "$1" == "on" ]; then
|
2024-08-04 19:31:25 -04:00
|
|
|
if [[ "$(${hyprctl} monitors all)" =~ \s(DP|HDMI)-[0-9]+ ]]; then
|
2024-07-19 13:59:48 -04:00
|
|
|
${hyprctl} keyword monitor "eDP-1, disable"
|
|
|
|
fi
|
|
|
|
elif [ "$1" == "off" ]; then
|
2024-08-02 20:56:49 -04:00
|
|
|
# Check if the monitor is disabled
|
|
|
|
if echo "$EDP_STATUS" | grep -q "disabled: true"; then
|
|
|
|
${
|
2024-07-19 13:59:48 -04:00
|
|
|
lib.strings.concatMapStringsSep "${hyprctl}\n"
|
|
|
|
(monitor: ''${hyprctl} keyword monitor "${monitor}"'')
|
|
|
|
cfg.desktop.hyprland.laptopMonitors
|
|
|
|
}
|
2024-08-02 20:56:49 -04:00
|
|
|
fi
|
2024-07-19 13:59:48 -04:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
tablet = pkgs.writeShellScript "hyprland-tablet" ''
|
|
|
|
STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled`
|
|
|
|
|
|
|
|
if [ $STATE -z ] || [ $STATE == "false" ]; then
|
|
|
|
if ! [ `pgrep -f ${virtKeyboard}` ]; then
|
|
|
|
${virtKeyboard} &
|
|
|
|
fi
|
|
|
|
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled true
|
|
|
|
elif [ $STATE == "true" ]; then
|
|
|
|
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled false
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
}
|