carousel apps
This commit is contained in:
1 parent
c3350c5c27
commit
33597a432c
10 files changed
+280
-15
No files matched your search
@@ -13,3 +13,95 @@ hl.env("NIXOS_OZONE_WL", "1")
|
||||
hl.env("QT_QPA_PLATFORM", "wayland")
|
||||
hl.env("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1")
|
||||
hl.env("ELECTRON_OZONE_PLATFORM_HINT", "auto")
|
||||
|
||||
---@param s string
|
||||
---@return string
|
||||
local function escape_pattern(s)
|
||||
return (s:gsub("([%.%-%+%[%]%(%)%$%^%%%?%*])", "%%%1"))
|
||||
end
|
||||
|
||||
---@param url string
|
||||
---@return fun(w: HL.Window): boolean
|
||||
local function make_target_validation_for_chromium_apps(url)
|
||||
local host = url:match("^https?://([^/]+)")
|
||||
local host_pattern = escape_pattern(host)
|
||||
---@param w HL.Window
|
||||
---@return boolean
|
||||
return function(w)
|
||||
if not w.class then
|
||||
return false
|
||||
end
|
||||
return w.class:match("^chrome%-" .. host_pattern)
|
||||
end
|
||||
end
|
||||
|
||||
---Focus an already-tagged window if one exists.
|
||||
---@param tag string
|
||||
---@return boolean
|
||||
local function attempt_to_switch_to_existing(tag)
|
||||
local existing = hl.get_windows({ tag = tag })
|
||||
|
||||
if existing and #existing > 0 then
|
||||
hl.dispatch(hl.dsp.focus({ window = existing[1] }))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
---@param tag string
|
||||
---@param cmd string
|
||||
---@param is_target_window fun(w: HL.Window): boolean
|
||||
---@return fun()
|
||||
local function make_commandable(tag, cmd, is_target_window)
|
||||
return function()
|
||||
if attempt_to_switch_to_existing(tag) then
|
||||
return
|
||||
end
|
||||
|
||||
---@type HL.EventSubscription
|
||||
local sub
|
||||
---@type hl.TimerHandle
|
||||
local timeout
|
||||
|
||||
---@param w HL.Window
|
||||
sub = hl.on("window.open", function(w)
|
||||
if not is_target_window(w) then
|
||||
return -- not our window, keep listening
|
||||
end
|
||||
sub:remove()
|
||||
timeout:set_enabled(false)
|
||||
hl.dispatch(hl.dsp.window.tag({ tag = "+" .. tag, window = w }))
|
||||
end)
|
||||
|
||||
timeout = hl.timer(function()
|
||||
sub:remove()
|
||||
end, { timeout = 5000, type = "oneshot" })
|
||||
|
||||
hl.dispatch(hl.dsp.exec_cmd(cmd))
|
||||
end
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param url string
|
||||
---@return fun()
|
||||
local function web_app(name, url)
|
||||
local tag = "skyg-" .. name
|
||||
local is_target_window = make_target_validation_for_chromium_apps(url)
|
||||
return make_commandable(
|
||||
tag,
|
||||
string.format("chromium --app=%s --new-window", url),
|
||||
is_target_window
|
||||
)
|
||||
end
|
||||
|
||||
---@type table<string, fun()>
|
||||
CarouselApps = CarouselApps or {}
|
||||
|
||||
CarouselApps.netflix = web_app("Netflix", "https://www.netflix.com/browse")
|
||||
CarouselApps.youtube = web_app("YouTube", "https://www.youtube.com")
|
||||
CarouselApps.jellyfin = web_app("Jellyfin", "http://bigbox1.lab.internal:8096")
|
||||
CarouselApps.paramountplus = web_app("paramountplus", "https://www.paramountplus.com")
|
||||
CarouselApps.primevideo = web_app("primevideo", "https://www.primevideo.com")
|
||||
CarouselApps.chromium = make_commandable("skyg-chromium", "chromium", function(w)
|
||||
return w.class == "chromium-browser"
|
||||
end)
|
||||
@@ -64,3 +64,8 @@ hl.window_rule({
|
||||
no_screen_share = true,
|
||||
xray = true,
|
||||
})
|
||||
hl.window_rule({
|
||||
match = { class = "^chrome-.*" },
|
||||
fullscreen = true,
|
||||
name = "fulll-chrome",
|
||||
})
|
||||
@@ -0,0 +1,92 @@
|
||||
---@param s string
|
||||
---@return string
|
||||
local function escape_pattern(s)
|
||||
return (s:gsub("([%.%-%+%[%]%(%)%$%^%%%?%*])", "%%%1"))
|
||||
end
|
||||
|
||||
---@param url string
|
||||
---@return fun(w: HL.Window): boolean
|
||||
local function make_target_validation_for_chromium_apps(url)
|
||||
local host = url:match("^https?://([^/]+)")
|
||||
local host_pattern = escape_pattern(host)
|
||||
---@param w HL.Window
|
||||
---@return boolean
|
||||
return function(w)
|
||||
if not w.class then
|
||||
return false
|
||||
end
|
||||
return w.class:match("^chrome%-" .. host_pattern)
|
||||
end
|
||||
end
|
||||
|
||||
---Focus an already-tagged window if one exists.
|
||||
---@param tag string
|
||||
---@return boolean
|
||||
local function attempt_to_switch_to_existing(tag)
|
||||
local existing = hl.get_windows({ tag = tag })
|
||||
|
||||
if existing and #existing > 0 then
|
||||
hl.dispatch(hl.dsp.focus({ window = existing[1] }))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
---@param tag string
|
||||
---@param cmd string
|
||||
---@param is_target_window fun(w: HL.Window): boolean
|
||||
---@return fun()
|
||||
local function make_commandable(tag, cmd, is_target_window)
|
||||
return function()
|
||||
if attempt_to_switch_to_existing(tag) then
|
||||
return
|
||||
end
|
||||
|
||||
---@type HL.EventSubscription
|
||||
local sub
|
||||
---@type hl.TimerHandle
|
||||
local timeout
|
||||
|
||||
---@param w HL.Window
|
||||
sub = hl.on("window.open", function(w)
|
||||
if not is_target_window(w) then
|
||||
return -- not our window, keep listening
|
||||
end
|
||||
hl.notification.create({ title = cmd, text = "Window opened", color = 1 })
|
||||
sub:remove()
|
||||
timeout:set_enabled(false)
|
||||
hl.dispatch(hl.dsp.window.tag({ tag = "+" .. tag, window = w }))
|
||||
end)
|
||||
|
||||
timeout = hl.timer(function()
|
||||
sub:remove()
|
||||
end, { timeout = 5000, type = "oneshot" })
|
||||
|
||||
hl.dispatch(hl.dsp.exec_cmd(cmd))
|
||||
end
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param url string
|
||||
---@return fun()
|
||||
local function web_app(name, url)
|
||||
local tag = "skyg-" .. name
|
||||
local is_target_window = make_target_validation_for_chromium_apps(url)
|
||||
return make_commandable(
|
||||
tag,
|
||||
string.format("chromium --app=%s --new-window", url),
|
||||
is_target_window
|
||||
)
|
||||
end
|
||||
|
||||
---@type table<string, fun()>
|
||||
CarouselApps = CarouselApps or {}
|
||||
|
||||
CarouselApps.netflix = web_app("Netflix", "https://www.netflix.com/browse")
|
||||
CarouselApps.youtube = web_app("YouTube", "https://www.youtube.com")
|
||||
CarouselApps.jellyfin = web_app("Jellyfin", "http://bigbox1.lab.internal:8096")
|
||||
CarouselApps.paramountplus = web_app("paramountplus", "https://www.paramountplus.com")
|
||||
CarouselApps.primevideo = web_app("primevideo", "https://www.primevideo.com")
|
||||
CarouselApps.chromium = make_commandable("skyg-chromium", "chromium", function(w)
|
||||
return w.class == "chromium-browser"
|
||||
end)
|
||||
@@ -35,3 +35,8 @@ hl.window_rule({
|
||||
match = { title = "^(Save File)$" },
|
||||
float = true,
|
||||
})
|
||||
hl.window_rule({
|
||||
match = { class = "^chrome-.*" },
|
||||
fullscreen = true,
|
||||
name = "fulll-chrome",
|
||||
})
|
||||
@@ -13,3 +13,4 @@ require("conf/inputs")
|
||||
require("conf/window-rules")
|
||||
require("conf/keybindings")
|
||||
require("conf/autostart")
|
||||
require("conf/apps")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -1,34 +1,45 @@
|
||||
{
|
||||
"autoStart": true,
|
||||
|
||||
"apps": [
|
||||
{
|
||||
"name": "Sosnovsky Video",
|
||||
"image": "~/.config/hypr/images/jellyfin.png",
|
||||
"exec": ["chromium", "--app=http://bigbox1.lab.internal:8096"]
|
||||
"image": "/home/ari/.config/hypr/images/jellyfin.png",
|
||||
"exec": ["hyprctl", "eval", "'CarouselApps.jellyfin()'"]
|
||||
},
|
||||
{
|
||||
"name": "Netflix",
|
||||
"image": "~/.config/hypr/images/Netflix.svg",
|
||||
"exec": ["chromium", "--app=https://www.netflix.com"]
|
||||
"image": "/home/ari/.config/hypr/images/Netflix.svg",
|
||||
"exec": ["hyprctl", "eval", "'CarouselApps.netflix()'"]
|
||||
},
|
||||
{
|
||||
"name": "Paramount+",
|
||||
"image": "https://www.paramountplus.com/assets/pplus/PPlus_Logo_1200x630_BLUE.png",
|
||||
"exec": ["chromium", "--app=https://www.paramountplus.com"]
|
||||
"exec": ["hyprctl", "eval", "'CarouselApps.paramountplus()'"]
|
||||
},
|
||||
{
|
||||
"name": "Prime Video",
|
||||
"image": "https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/mstile-310x150.png",
|
||||
"exec": ["chromium", "--app=https://www.primevideo.com"]
|
||||
"exec": ["hyprctl", "eval", "'CarouselApps.primevideo()'"]
|
||||
},
|
||||
{
|
||||
"name": "YouTube",
|
||||
"image": "/home/ari/.config/hypr/images/youtube.webp",
|
||||
"exec": ["hyprctl", "eval", "'CarouselApps.youtube()'"]
|
||||
},
|
||||
{
|
||||
"name": "Chromium",
|
||||
"image": "~/.config/hypr/images/Chromium.svg",
|
||||
"exec": ["chromium"]
|
||||
"image": "/home/ari/.config/hypr/images/Chromium.svg",
|
||||
"exec": ["hyprctl", "eval", "'CarouselApps.chromium()'"]
|
||||
},
|
||||
{
|
||||
"name": "Spotify",
|
||||
"image": "/var/lib/flatpak/app/com.spotify.Client/current/active/export/share/icons/hicolor/scalable/apps/com.spotify.Client.svg",
|
||||
"exec": ["flatpak", "run", "com.spotify.Client"]
|
||||
},
|
||||
{
|
||||
"name": "Settings",
|
||||
"image": "~/.config/hypr/images/settings.png",
|
||||
"image": "/home/ari/.config/hypr/images/settings.png",
|
||||
"exec": ["dms", "ipc", "call", "settings", "toggle"]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
---@field direction? "left"|"right"|"up"|"down" Focus by direction
|
||||
---@field workspace? string|integer e.g. "e-1", "e+1", or a numeric id
|
||||
---@field monitor? string e.g. "+1", "-1", name
|
||||
---@field window? HL.Window Focus a specific window
|
||||
---@field on_current_monitor? boolean Switch to the workspace on the current monitor
|
||||
|
||||
---@class hl.dsp.MoveOpts
|
||||
@@ -108,6 +109,15 @@ function dsp_window.resize(opts) end
|
||||
---@return hl.DispatcherValue
|
||||
function dsp_window.drag() end
|
||||
|
||||
---@class hl.dsp.TagOpts
|
||||
---@field tag string Tag expression, e.g. "+skyg-Netflix"
|
||||
---@field window? HL.Window Window to tag (focused window if omitted)
|
||||
|
||||
---Set or unset tags on a window.
|
||||
---@param opts hl.dsp.TagOpts
|
||||
---@return hl.DispatcherValue
|
||||
function dsp_window.tag(opts) end
|
||||
|
||||
---@class hl.dsp.group
|
||||
local dsp_group = {}
|
||||
|
||||
@@ -332,9 +342,15 @@ function RuleHandle:set_enabled(enabled) end
|
||||
-- hl.on — event hooks
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
---@class HL.EventSubscription
|
||||
local EventSubscription = {}
|
||||
---Stop listening for this event.
|
||||
function EventSubscription:remove() end
|
||||
|
||||
---Register a callback for a Hyprland event.
|
||||
---@param event string e.g. "hyprland.start", "window.open", "monitor.added"
|
||||
---@param callback fun()
|
||||
---@param callback fun(...: any)
|
||||
---@return HL.EventSubscription
|
||||
function hl.on(event, callback) end
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -356,9 +372,12 @@ local plugin = {}
|
||||
---@param path string Absolute path to the shared library
|
||||
function plugin.load(path) end
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- hl.get_workspaces — runtime introspection
|
||||
-- hl.get_workspaces / hl.get_windows — runtime introspection
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
---@alias HL.MonitorSelector string|integer|HL.Monitor
|
||||
---@alias HL.WorkspaceSelector string|integer|HL.Workspace
|
||||
|
||||
---@class HL.Monitor
|
||||
---@field id integer
|
||||
---@field name string
|
||||
@@ -383,10 +402,45 @@ function plugin.load(path) end
|
||||
---@field is_empty? boolean
|
||||
---@field monitor? HL.Monitor
|
||||
|
||||
---@class HL.Window
|
||||
---@field address string
|
||||
---@field class string
|
||||
---@field title string
|
||||
---@field initial_class string
|
||||
---@field initial_title string
|
||||
---@field active boolean
|
||||
---@field floating boolean
|
||||
---@field fullscreen integer
|
||||
---@field mapped boolean
|
||||
---@field pinned boolean
|
||||
---@field hidden boolean
|
||||
---@field visible boolean
|
||||
---@field xwayland boolean
|
||||
---@field pid integer
|
||||
---@field stable_id string
|
||||
---@field focus_history_id integer
|
||||
---@field monitor? HL.Monitor
|
||||
---@field workspace? HL.Workspace
|
||||
---@field tags? string|table
|
||||
|
||||
---@class HL.WindowQueryFilter
|
||||
---@field class? string Regex matched against window class (app_id)
|
||||
---@field title? string Regex matched against window title
|
||||
---@field tag? string Match by window tag (see hl.dsp.window.tag)
|
||||
---@field floating? boolean
|
||||
---@field mapped? boolean
|
||||
---@field monitor? HL.MonitorSelector
|
||||
---@field workspace? HL.WorkspaceSelector
|
||||
|
||||
---All non-inert workspaces.
|
||||
---@return HL.Workspace[]
|
||||
function hl.get_workspaces() end
|
||||
|
||||
---Windows matching an optional filter (all windows when omitted).
|
||||
---@param filters? HL.WindowQueryFilter
|
||||
---@return HL.Window[]
|
||||
function hl.get_windows(filters) end
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- hl.print — log to the Hyprland log
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -414,6 +468,9 @@ function hl.dispatch(action) end
|
||||
local TimerHandle = {}
|
||||
---Cancel this timer.
|
||||
function TimerHandle:cancel() end
|
||||
---Enable or disable this timer.
|
||||
---@param enabled boolean
|
||||
function TimerHandle:set_enabled(enabled) end
|
||||
|
||||
---Schedule a callback on a repeating or one-shot timer.
|
||||
---@param callback fun()
|
||||
|
||||
@@ -137,10 +137,6 @@ in
|
||||
enable = true;
|
||||
user = "ari";
|
||||
};
|
||||
# home manager - only configure if skyg.user.enable is true
|
||||
home-manager.users.${user.name} = lib.mkIf config.skyg.user.enable {
|
||||
services.blueman-applet.enable = true;
|
||||
};
|
||||
# Firmware updater
|
||||
services.fwupd.enable = true;
|
||||
# Bluetooth
|
||||
|
||||
@@ -58,4 +58,10 @@
|
||||
environment.systemPackages = with pkgs; [
|
||||
skygqts
|
||||
];
|
||||
|
||||
# Flatpaks
|
||||
services.flatpak.enable = true;
|
||||
services.flatpak.packages = [
|
||||
"com.spotify.Client"
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user