[user/malte] Implement do-not-disturb mode
This commit is contained in:
parent
6c1e8ebb26
commit
64b5b51b01
65
pkgs/do-not-disturb.nix
Normal file
65
pkgs/do-not-disturb.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
# Small script to toggle DO-NOT-DISTURB mode
|
||||
# and make it integrate well with other applications
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellApplication {
|
||||
name = "do-not-disturb";
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
mako
|
||||
systemd
|
||||
];
|
||||
text = ''
|
||||
MAKO_DEFAULT_MODE=default
|
||||
MAKO_SILENT_MODE=do-not-disturb
|
||||
|
||||
# Sanity checks
|
||||
if [ -z "''${1+x}" ]; then
|
||||
print_help
|
||||
fi
|
||||
if [ -z "''${XDG_RUNTIME_DIR+x}" ]; then
|
||||
printf "XDG_RUNTIME_DIR undefined! Cannot connect to mako!\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
state="$XDG_RUNTIME_DIR/do-not-disturb"
|
||||
|
||||
# Print usage information
|
||||
function print_help() {
|
||||
printf "Usage:\n"
|
||||
printf " %s [ toggle | is-on | is-off | get-file ]\n" "$0"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Toggle the mode
|
||||
function toggle() {
|
||||
if [ -f "$state" ]; then
|
||||
rm "$state"
|
||||
else
|
||||
touch "$state"
|
||||
fi
|
||||
}
|
||||
|
||||
# Update mako's mode to this scripts mode
|
||||
function update-mako() {
|
||||
if [ -f "$state" ]; then
|
||||
makoctl set-mode $MAKO_SILENT_MODE
|
||||
else
|
||||
makoctl set-mode $MAKO_DEFAULT_MODE
|
||||
fi
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "$action" = "toggle" ]; then
|
||||
toggle
|
||||
update-mako
|
||||
elif [ "$action" = "is-on" ]; then
|
||||
[ -f "$state" ]
|
||||
elif [ "$action" = "is-off" ]; then
|
||||
[ ! -f "$state" ]
|
||||
elif [ "$action" = "get-file" ]; then
|
||||
printf "%s" "$state"
|
||||
else
|
||||
print_help
|
||||
fi
|
||||
'';
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
...
|
||||
}: let
|
||||
col = config.colors;
|
||||
doNotDisturb = pkgs.callPackage ../../pkgs/do-not-disturb.nix {};
|
||||
in {
|
||||
programs.mako = {
|
||||
enable = true;
|
||||
|
@ -18,7 +19,7 @@ in {
|
|||
width = 400;
|
||||
height = 500;
|
||||
format = ''
|
||||
<span color='${col.dark2.hashRgb}'><i>%a</i></span>\n<b>%s</b> %b"'';
|
||||
<span color='${col.dark2.hashRgb}'><i>%a</i></span>\n<b>%s</b> %b'';
|
||||
layer = "overlay";
|
||||
margin = "5";
|
||||
padding = "6";
|
||||
|
@ -44,6 +45,9 @@ in {
|
|||
background-color=${col.light4.hashRgb}
|
||||
format=... %h more
|
||||
|
||||
[mode=do-not-disturb]
|
||||
invisible=1
|
||||
|
||||
[app-name=fish urgency=normal]
|
||||
background-color=${col.brightGreen.hashRgb}
|
||||
format= <b>%s</b>\n%b
|
||||
|
@ -74,5 +78,8 @@ in {
|
|||
Install = {WantedBy = ["graphical-session.target"];};
|
||||
};
|
||||
|
||||
home.packages = [pkgs.hackNerdLigatures];
|
||||
home.packages = [
|
||||
pkgs.hackNerdLigatures
|
||||
doNotDisturb
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
slurp = "${pkgs.slurp}/bin/slurp -db '#000000AA' -c '${col.light1.hashRgb}' -w1";
|
||||
fuser = "${pkgs.psmisc}/bin/fuser";
|
||||
alsa_rec = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink.monitor";
|
||||
doNotDisturb = pkgs.callPackage ../../pkgs/do-not-disturb.nix {};
|
||||
|
||||
screenshot-path = "/home/malte/Pictures/screenshots/screenshot.png";
|
||||
screenshot-all = "${grim} ${screenshot-path} && ${wl-copy} < ${screenshot-path}";
|
||||
|
@ -221,6 +222,8 @@ in {
|
|||
"${mod}+Ctrl+Shift+w" = "mode window";
|
||||
# Screenlocking
|
||||
"XF86Favorites" = "exec swaylock";
|
||||
# Toggle DO-NOT-DISTURB mode
|
||||
"${mod}+n" = "exec ${doNotDisturb}/bin/do-not-disturb toggle";
|
||||
};
|
||||
|
||||
gaps = let
|
||||
|
|
|
@ -40,6 +40,23 @@
|
|||
}" | ${jq} --unbuffered --compact-output
|
||||
'';
|
||||
|
||||
doNotDisturbJson = pkgs.writeShellApplication {
|
||||
name = "do-not-disturb-json";
|
||||
runtimeInputs = [
|
||||
(pkgs.callPackage ../../pkgs/do-not-disturb.nix {})
|
||||
pkgs.coreutils
|
||||
pkgs.jq
|
||||
];
|
||||
text = ''
|
||||
state=$(do-not-disturb get-file)
|
||||
if [ -f "$state" ]; then
|
||||
printf "{ \"text\": \" \", \
|
||||
\"tooltip\": \"DO NOT DISTURB!\" \
|
||||
}" | jq --unbuffered --compact-output
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
new-mail = let
|
||||
notmuch = "${pkgs.notmuch}/bin/notmuch";
|
||||
wc = "${pkgs.coreutils}/bin/wc";
|
||||
|
@ -96,7 +113,7 @@ in {
|
|||
|
||||
modules-left = ["sway/workspaces" "sway/mode" "sway/window"];
|
||||
modules-center = ["clock#time" "custom/check-system" "clock#date"];
|
||||
modules-right = ["custom/taskwarrior" "custom/new-mail" "network" "battery" "tray"];
|
||||
modules-right = ["custom/do-not-disturb" "custom/taskwarrior" "custom/new-mail" "network" "battery" "tray"];
|
||||
|
||||
modules = {
|
||||
"sway/workspaces" = {
|
||||
|
@ -123,6 +140,11 @@ in {
|
|||
tooltip = false;
|
||||
};
|
||||
|
||||
"custom/do-not-disturb" = {
|
||||
exec = "${doNotDisturbJson}/bin/do-not-disturb-json";
|
||||
return-type = "json";
|
||||
interval = 1;
|
||||
};
|
||||
"custom/taskwarrior" = {
|
||||
exec = "${task-activity}/bin/task-activity";
|
||||
return-type = "json";
|
||||
|
@ -254,14 +276,16 @@ in {
|
|||
#battery,
|
||||
#network,
|
||||
#mode,
|
||||
#custom-taskwarrior
|
||||
#custom-new-mail
|
||||
#custom-taskwarrior,
|
||||
#custom-do-not-disturb,
|
||||
#custom-new-mail,
|
||||
#custom-check-system {
|
||||
padding: 0 10px;
|
||||
color: ${col.light2.hashRgb};
|
||||
}
|
||||
|
||||
#custom-taskwarrior,
|
||||
#custom-do-not-disturb,
|
||||
#custom-new-mail {
|
||||
padding: 0px 10px 0px 13px;
|
||||
margin-right: 10px;
|
||||
|
@ -271,6 +295,11 @@ in {
|
|||
border-bottom: 3px solid ${(col.brightYellow.darker darkenBorder).hashRgb};
|
||||
}
|
||||
|
||||
#custom-do-not-disturb {
|
||||
background-color: ${col.neutralGreen.hashRgb};
|
||||
border-bottom: 3px solid ${(col.neutralGreen.darker darkenBorder).hashRgb};
|
||||
}
|
||||
|
||||
#custom-check-system {
|
||||
margin: 0 5px;
|
||||
padding: 0 10px 0 13px;
|
||||
|
|
Loading…
Reference in a new issue