-- See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules

-- {{{ Floating windows
-- Generated by hyprlang2lua. Review TODOs before reloading Hyprland.

hl.window_rule({
	match = {
		class = "discord",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "mpv",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "anki",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "steam",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "python",
		title = "Import",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "zenity",
		title = "Japanese Analysis",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "zenity",
		title = "Japanese Assistant",
	},
	float = true,
})

hl.window_rule({
	match = {
		class = "anki",
	},
	-- TODO: manual review — unmapped window rule action: "min_size 1600 600"
	-- TODO: manual review — unmapped window rule action: "max_size 2222 1234"
})

hl.window_rule({
	match = {
		class = "^ueberzugpp_.*$",
	},
	float = true,
	center = false,
	no_initial_focus = true,
	no_focus = true,
	no_follow_mouse = true,
	border_size = 0,
	rounding = 0,
	no_shadow = true,
	no_anim = true,
})

hl.window_rule({
	match = {
		class = "anki",
	},
	size = "1920 1080",
})

-- windowrule = min_size 1600 600, match:class anki
-- windowrule = max_size 2222 1234, match:class anki
-- }}}

-- {{{ Workspace assignments
hl.window_rule({
	match = {
		class = "Cursor",
	},
	workspace = "3 silent",
})

hl.window_rule({
	match = {
		class = "GameSentenceMiner",
	},
	workspace = "5 silent",
})

hl.window_rule({
	match = {
		class = "com.obsproject.Studio",
	},
	workspace = "5 silent",
})

hl.window_rule({
	match = {
		class = "gamescope",
	},
	workspace = "6 silent",
})

hl.window_rule({
	match = {
		class = "anki",
	},
	workspace = "8 silent",
})

hl.window_rule({
	match = {
		class = "steam",
	},
	workspace = "9 silent",
})

hl.window_rule({
	match = {
		class = "discord",
	},
	workspace = "10 silent",
})

-- }}}

-- {{{ Center floating windows
hl.window_rule({
	match = {
		float = 1,
		class = "discord",
	},
	center = true,
})

hl.window_rule({
	match = {
		float = 1,
		class = "anki",
	},
	center = true,
})

-- }}}

-- {{{ Opacity rules
-- windowrule = opacity 0.88, match:class .* fullscreen:0
hl.window_rule({
	match = {
		class = "mpv",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "^(remote-viewer)$",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "com.obsproject.Studio",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		title = "(.*)(- YouTube(.*))",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "zen",
		title = "(.*)YouTube TV(.*)",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "anki",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		title = "(.*)asbplayer",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "dolphin-emu",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "steam_app_default",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "steam_app.*",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "Rustdesk",
	},
	opacity = "1.0 override",
})

hl.window_rule({
	match = {
		class = "google-chrome",
	},
	opacity = "1.0 override",
})

-- }}}

-- {{{ Misc
hl.window_rule({
	match = {
		title = "(.*)asbplayer",
	},
	-- TODO: manual review — unmapped window rule action: "tile on"
})

-- windowrule = size 2118 1182, match:class anki
-- Ignore maximize requests from apps. You'll probably like this.
hl.window_rule({
	match = {
		class = ".*",
	},
	suppress_event = "maximize",
})

-- Fix some dragging issues with XWayland
hl.window_rule({
	match = {
		class = "^$",
		title = "^$",
		xwayland = 1,
		float = 1,
		fullscreen = 0,
		pin = 0,
	},
	-- TODO: manual review — unmapped window rule action: "no_focus on"
})

-- }}}

-- {{{ Screen sharing workaround: https://wiki.hyprland.org/Useful-Utilities/Screen-Sharing/#xwayland
hl.window_rule({
	match = {
		class = "^(xwaylandvideobridge)$",
	},
	opacity = "0.0 override",
	-- TODO: manual review — unmapped window rule action: "no_anim on"
	-- TODO: manual review — unmapped window rule action: "no_initial_focus on"
	-- TODO: manual review — unmapped window rule action: "max_size 1 1"
	-- TODO: manual review — unmapped window rule action: "no_blur on"
	-- TODO: manual review — unmapped window rule action: "no_focus on"
})

-- }}}

-- {{{ GSM Overlay and LunaTranslator tweaks
hl.window_rule({
	match = {
		class = "gsm_overlay",
	},
	float = true,
	-- TODO: manual review — unmapped window rule action: "border_size 0"
	-- TODO: manual review — unmapped window rule action: "xray off"
	-- TODO: manual review — unmapped window rule action: "no_shadow on"
	-- TODO: manual review — unmapped window rule action: "no_blur on"
})

hl.window_rule({
	match = {
		title = "LunaTranslator",
	},
	opacity = "1.0 override",
	-- TODO: manual review — unmapped window rule action: "border_size 0"
})

hl.window_rule({
	match = {
		class = "gsm_overlay",
	},
	-- TODO: manual review — unmapped window rule action: "stay_focused on"
})

-- windowrule = fullscreen_state 2, match:class gsm_overlay

hl.window_rule({
	match = {
		class = "steam_app_1277940",
	},
	-- TODO: manual review — unmapped window rule action: "border_size 0"
})

hl.window_rule({
	match = {
		class = "^SubMiner$",
	},
	float = true,
	border_size = 0,
	xray = false,
	no_shadow = true,
	no_blur = true,
	no_dim = true,
	opaque = true,
	dim_around = false,
	opacity = "1.0 override 1.0 override",
	pin = false,
})

hl.window_rule({
	match = {
		class = "^gamesentenceminer$",
		title = "GSM Overlay",
	},
	float = true,
	border_size = 0,
	xray = false,
	no_shadow = true,
	no_blur = true,
	no_dim = true,
	opaque = true,
	dim_around = false,
	opacity = "1.0 override 1.0 override",
	pin = false,
})

-- }}}

-- {{{ FEH
hl.window_rule({
	match = {
		class = "feh",
	},
	float = true,
	center = true,
	-- TODO: manual review — unmapped window rule action: "border_size 0"
	-- TODO: manual review — unmapped window rule action: "no_shadow on"
	-- TODO: manual review — unmapped window rule action: "no_blur on"
	-- TODO: manual review — unmapped window rule action: "no_anim on"
})

-- }}}

hl.window_rule({
	match = {
		title = "Picture in picture",
	},
	float = true,
	pin = true,
})

-- TODO: manual review — top-level key 'windowurle = no_vrr on, match:class mpv' has no enclosing section

-- aibar popup (AI usage widget)
hl.window_rule({
	match = {
		title = "aibar",
	},
	float = true,
	move = "100%-374 50",
})
