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") printf (env LANG=ja_JP.UTF-8 date +"\n%A%Y%m%d%H%M \n\n")
end 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 # Set up an editor alias
if test -n "$EDITOR" if test -n "$EDITOR"
alias e="$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 ${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 in
{ {
@ -127,42 +129,48 @@ in
# #
# Main modifier # Main modifier
modifier = mod; modifier = mod;
keybindings = lib.mkOptionDefault keybindings = lib.mkOptionDefault ({
( ## Splits
"${mod}+v" = "split v";
"${mod}+Shift+v" = "split h";
## Run
"${mod}+r" = "exec ${config.wayland.windowManager.sway.config.menu}";
"${mod}+Shift+r" = "mode resize";
## Screenshot
"Print" = "exec ${screenshotScript}/bin/screenshot";
## Locking
"${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
(key: [
{ {
## Splits name = "${mod}+${key}";
"${mod}+v" = "split v"; value = "workspace ${builtins.getAttr key wsAttrs}";
"${mod}+Shift+v" = "split h";
## Run
"${mod}+r" = "exec ${config.wayland.windowManager.sway.config.menu}";
"${mod}+Shift+r" = "mode resize";
## Screenshot
"Print" = "exec ${screenshotScript}/bin/screenshot";
## Locking
"${mod}+semicolon" = "exec ${pkgs.swaylock}/bin/swaylock"
+ (if cfg.wallpaper == "" then "" else " -i ${cfg.wallpaper} -s fit")
+ " -l -k";
} //
# Map the workspaces
(builtins.listToAttrs (lib.flatten (map
(key: [
{
name = "${mod}+${key}";
value = "workspace ${builtins.getAttr key wsAttrs}";
}
{
name = "${mod}+Shift+${key}";
value = "move to workspace ${builtins.getAttr key wsAttrs}";
}
])
(builtins.attrNames wsAttrs))
)) //
# Move workspaces between outputs
{
"${mod}+ctrl+h" = "move workspace to output left";
"${mod}+ctrl+l" = "move workspace to output right";
} }
); {
name = "${mod}+Shift+${key}";
value = "move to workspace ${builtins.getAttr key wsAttrs}";
}
])
(builtins.attrNames wsAttrs))
)) //
# Move workspaces between outputs
{
"${mod}+ctrl+h" = "move workspace to output left";
"${mod}+ctrl+l" = "move workspace to output right";
});
### Fonts ### Fonts
# #
@ -257,32 +265,42 @@ in
modules-left = [ modules-left = [
"sway/workspaces" "sway/workspaces"
"sway/mode" "sway/mode"
];
modules-center = [
"sway/window" "sway/window"
]; ];
modules-right = modules-center = [
(if cfg.enableMpd then [ "mpd" ] else [ ]) ];
++ [ modules-right = [
"tray" (if cfg.enableMpd then "mpd" else "custom/media")
"pulseaudio" "tray"
"network" "pulseaudio"
"cpu" "network"
"memory" "cpu"
"temperature" "memory"
"backlight" "temperature"
] ++ ( "backlight"
if cfg.enableLaptopBars ] ++ (
then [ "battery" "battery#bat2" ] if cfg.enableLaptopBars
else [ ] then [ "battery" "battery#bat2" ]
) ++ [ else [ ]
"clock" ) ++ [
]; "clock"
];
modules = { modules = {
"sway/mode" = { "sway/mode" = {
format = "<span style=\"italic\">{}</span>"; 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" = { "tray" = {
icon-size = 21; icon-size = 21;
spacing = 10; spacing = 10;
@ -372,6 +390,17 @@ in
"tooltip-format" = "MPD (connected)"; "tooltip-format" = "MPD (connected)";
"tooltip-format-disconnected" = "MPD (disconnected)"; "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; background-color: #eb4d4b;
} }
#window, #sway, #sway-window {
padding: 0 10px;
}
#mode { #mode {
background: #64727D; background: #64727D;
border-bottom: 3px solid #ffffff; border-bottom: 3px solid #ffffff;