Some fancy title rewriting

This commit is contained in:
Natsu Kagami 2022-10-31 12:05:14 +01:00
parent b0a826a881
commit e6652536fe
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
2 changed files with 92 additions and 53 deletions

View file

@ -38,6 +38,12 @@
printf (env LANG=ja_JP.UTF-8 date +"\n%A%Y%m%d%H%M \n\n")
end
functions --copy fish_title __original_fish_title
functions --erase fish_title
function fish_title
echo (__original_fish_title) - fish
end
# Set up an editor alias
if test -n "$EDITOR"
alias e="$EDITOR"

View file

@ -35,6 +35,8 @@ let
${pkgs.grim}/bin/grim -g (${pkgs.slurp}/bin/slurp) - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png
'';
ignored-devices = [ "Surface_Headphones" ];
playerctl = "${pkgs.playerctl}/bin/playerctl --ignore-player=${strings.concatStringsSep "," ignored-devices}";
in
{
@ -127,9 +129,7 @@ in
#
# Main modifier
modifier = mod;
keybindings = lib.mkOptionDefault
(
{
keybindings = lib.mkOptionDefault ({
## Splits
"${mod}+v" = "split v";
"${mod}+Shift+v" = "split h";
@ -142,6 +142,15 @@ in
"${mod}+semicolon" = "exec ${pkgs.swaylock}/bin/swaylock"
+ (if cfg.wallpaper == "" then "" else " -i ${cfg.wallpaper} -s fit")
+ " -l -k";
## Multimedia
"XF86AudioPrev" = "exec ${playerctl} previous";
"XF86AudioPlay" = "exec ${playerctl} play-pause";
"Shift+XF86AudioPlay" = "exec ${playerctl} stop";
"XF86AudioNext" = "exec ${playerctl} next";
"XF86AudioRecord" = "exec ${pkgs.alsa-utils}/bin/amixer -q set Capture toggle";
"XF86AudioMute" = "exec ${pkgs.alsa-utils}/bin/amixer -q set Master toggle";
"XF86AudioLowerVolume" = "exec ${pkgs.alsa-utils}/bin/amixer -q set Master 3%-";
"XF86AudioRaiseVolume" = "exec ${pkgs.alsa-utils}/bin/amixer -q set Master 3%+";
} //
# Map the workspaces
(builtins.listToAttrs (lib.flatten (map
@ -161,8 +170,7 @@ in
{
"${mod}+ctrl+h" = "move workspace to output left";
"${mod}+ctrl+l" = "move workspace to output right";
}
);
});
### Fonts
#
@ -257,13 +265,12 @@ in
modules-left = [
"sway/workspaces"
"sway/mode"
];
modules-center = [
"sway/window"
];
modules-right =
(if cfg.enableMpd then [ "mpd" ] else [ ])
++ [
modules-center = [
];
modules-right = [
(if cfg.enableMpd then "mpd" else "custom/media")
"tray"
"pulseaudio"
"network"
@ -283,6 +290,17 @@ in
"sway/mode" = {
format = "<span style=\"italic\">{}</span>";
};
"sway/window" = {
max-length = 70;
format = "{title}";
"rewrite" = {
"(.*) Mozilla Firefox" = "🌎 $1";
"(.*) - Kakoune" = "$1";
"(.*) - fish" = ">_ $1";
" Discord \\| (.*)" = "🗨 $1";
"\\((\\d+)\\) Discord \\| (.*)" = "🗨 [$1] $2";
};
};
"tray" = {
icon-size = 21;
spacing = 10;
@ -372,6 +390,17 @@ in
"tooltip-format" = "MPD (connected)";
"tooltip-format-disconnected" = "MPD (disconnected)";
};
"custom/media" = {
"format" = "{icon}{}";
"return-type" = "json";
"format-icons" = {
"Playing" = " ";
"Paused" = " ";
};
"max-length" = 80;
"exec" = "${playerctl} -a metadata --format '{\"text\": \"{{artist}} - {{markup_escape(title)}}\", \"tooltip\": \"{{playerName}} : {{markup_escape(title)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}' -F";
"on-click" = "${playerctl} play-pause";
};
};
}
];
@ -410,6 +439,10 @@ in
background-color: #eb4d4b;
}
#window, #sway, #sway-window {
padding: 0 10px;
}
#mode {
background: #64727D;
border-bottom: 3px solid #ffffff;