waybar: Add security key interaction notification
This commit is contained in:
parent
013511c1c9
commit
ec150e5a6c
8
LICENSES/ISC.txt
Normal file
8
LICENSES/ISC.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
ISC License:
|
||||||
|
|
||||||
|
Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
Copyright (c) 1995-2003 by Internet Software Consortium
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@ -27,4 +27,17 @@
|
||||||
maxCacheTtl = 1800;
|
maxCacheTtl = 1800;
|
||||||
maxCacheTtlSsh = maxCacheTtl;
|
maxCacheTtlSsh = maxCacheTtl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.user.services.yubikey-touch-detector = {
|
||||||
|
Unit.PartOf = [ "sway-session.target" ];
|
||||||
|
Install.WantedBy = [ "sway-session.target" ];
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
Environment = [
|
||||||
|
"PATH=${pkgs.gnupg}/bin"
|
||||||
|
];
|
||||||
|
ExecStart = "${pkgs.yubikey-touch-detector}/bin/yubikey-touch-detector";
|
||||||
|
Restart = "on-failure";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
45
users/simon/modules/sway/waybar-interaction
Executable file
45
users/simon/modules/sway/waybar-interaction
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#! @bash@/bin/bash
|
||||||
|
# shellcheck disable=SC2239
|
||||||
|
# SPDX-FileCopyrightText: 2020 Maxim Baz <git@maximbaz.com>
|
||||||
|
# SPDX-FileCopyrightText: 2023 Matthew Monaco <matt@monaco.cx>
|
||||||
|
# SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: ISC
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
socket="${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-touch-detector.socket"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
touch_reasons=()
|
||||||
|
|
||||||
|
if [ ! -e "$socket" ]; then
|
||||||
|
printf '{"text": "Waiting for socket"}\n'
|
||||||
|
while [ ! -e "$socket" ]; do sleep 1; done
|
||||||
|
fi
|
||||||
|
printf '{"text": ""}\n'
|
||||||
|
|
||||||
|
while read -r -n5 cmd; do
|
||||||
|
reason="${cmd:0:3}"
|
||||||
|
|
||||||
|
if [ "${cmd:4:1}" = "1" ]; then
|
||||||
|
touch_reasons+=("$reason")
|
||||||
|
else
|
||||||
|
for i in "${!touch_reasons[@]}"; do
|
||||||
|
if [ "${touch_reasons[i]}" = "$reason" ]; then
|
||||||
|
unset 'touch_reasons[i]'
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#touch_reasons[@]}" -eq 0 ]; then
|
||||||
|
printf '{"text": ""}\n'
|
||||||
|
else
|
||||||
|
tooltip="Security key is waiting for a touch, reasons: ${touch_reasons[*]}"
|
||||||
|
printf '{"text": "", "tooltip": "%s"}\n' "$tooltip"
|
||||||
|
fi
|
||||||
|
done < <(@netcat@/bin/nc -U "$socket")
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2022 Simon Bruder <simon@sbruder.de>
|
* SPDX-FileCopyrightText: 2020-2024 Simon Bruder <simon@sbruder.de>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
@ -178,3 +178,13 @@ window#waybar {
|
||||||
background-color: @base3@;
|
background-color: @base3@;
|
||||||
color: @base00@;
|
color: @base00@;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#custom-interaction {
|
||||||
|
background-color: @yellow@;
|
||||||
|
color: @base03@;
|
||||||
|
animation-name: blink;
|
||||||
|
animation-duration: 0.5s;
|
||||||
|
animation-timing-function: cubic-bezier(1, 0, 0, 1);
|
||||||
|
animation-iteration-count: infinite;
|
||||||
|
animation-direction: alternate;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# SPDX-FileCopyrightText: 2020-2023 Simon Bruder <simon@sbruder.de>
|
# SPDX-FileCopyrightText: 2020-2024 Simon Bruder <simon@sbruder.de>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ in
|
||||||
];
|
];
|
||||||
modules-right = [
|
modules-right = [
|
||||||
"tray"
|
"tray"
|
||||||
|
"custom/interaction"
|
||||||
"custom/screencast"
|
"custom/screencast"
|
||||||
"custom/redshift"
|
"custom/redshift"
|
||||||
"idle_inhibitor"
|
"idle_inhibitor"
|
||||||
|
@ -81,6 +82,15 @@ in
|
||||||
deactivated = " ";
|
deactivated = " ";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
"custom/interaction" = {
|
||||||
|
exec = pkgs.substituteAll ({
|
||||||
|
src = ./waybar-interaction;
|
||||||
|
} // {
|
||||||
|
inherit (pkgs) netcat bash;
|
||||||
|
isExecutable = true;
|
||||||
|
});
|
||||||
|
return-type = "json";
|
||||||
|
};
|
||||||
"custom/screencast" = {
|
"custom/screencast" = {
|
||||||
exec = pkgs.writeScript "screencast-monitor" /* python */ ''
|
exec = pkgs.writeScript "screencast-monitor" /* python */ ''
|
||||||
#!${pkgs.python3}/bin/python3
|
#!${pkgs.python3}/bin/python3
|
||||||
|
|
Loading…
Reference in a new issue