diff --git a/config.json b/config.json new file mode 100644 index 0000000..872860b --- /dev/null +++ b/config.json @@ -0,0 +1,29 @@ +{ + "wallpapers_dir": "~/Pictures/Wallpapers/", + "dock_position": "Bottom", + "terminal_command": "kitty -e", + "dock_enabled": true, + "dock_auto_hide": true, + "dock_always_occluded": false, + "dock_icon_size": 52, + "window_switcher_items_per_row": 10, + "hide_special_workspace": true, + "dock_hide_special_workspace_apps": true, + "notification_timeout": "5s", + "notification_ignored_apps": ["Hyprshot"], + "notification_limited_apps_history": ["Spotify"], + "imac_button": true, + "systray": true, + "control_center": true, + "search": true, + "global_menu": true, + "network": true, + "battery": true, + "notification_center": true, + "workspace_indicator": true, + "bluetooth": true, + "date_time": true, + "dock": true, + "window_switcher": true +} + diff --git a/styles/about.css b/styles/about.css index 77ace66..709515b 100644 --- a/styles/about.css +++ b/styles/about.css @@ -68,7 +68,6 @@ } #more-info-button:hover { background-color: rgb(72, 130, 255); - background-color: #2369ff; } #more-info-button label { diff --git a/styles/battery-widget.css b/styles/battery.css similarity index 93% rename from styles/battery-widget.css rename to styles/battery.css index 763cfe4..27035c3 100644 --- a/styles/battery-widget.css +++ b/styles/battery.css @@ -1,3 +1,11 @@ +#battery-window { + margin: 6px; + /* background-color: alpha(#fff, 0.09); */ + border: 1px solid alpha(#111, 0.3); + box-shadow: inset 0 0 200px 0 alpha(#111, 0.3); + border-radius: 8px; +} + #battery-widget { background: rgba(0, 0, 0, 0); padding-left: 5px; diff --git a/styles/constant.css b/styles/constant.css new file mode 100644 index 0000000..0d4bfe4 --- /dev/null +++ b/styles/constant.css @@ -0,0 +1,6 @@ +@define-color bg alpha(#fff, 0.07); +@define-color hover alpha(#fff, 0.1); + +@define-color border var(--outline); +@define-color active alpha(#fff, 0.9); +@define-color urgent alpha(var(--on-error), 0.7); diff --git a/styles/dock.css b/styles/dock.css index 24eb0f7..e69de29 100644 --- a/styles/dock.css +++ b/styles/dock.css @@ -1,98 +0,0 @@ -#dock { - background-color: alpha(#fff, 0.07); - padding: 4px 4px; - margin: 4px 4px; - border: none; - border-radius: 16px; - transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1); -} - -#dock.shown { - transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1); -} - -#dock_item_main_container { - transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1); -} - -#dock_item.shown:hover #dock_item_main_container { - margin-top: -12px; -} - -#dock_item.shown.semi_hovered #dock_item_main_container { - margin-top: -7px; -} -/**/ -/* #dock_item.shown.semi_hovered #dock_item_indicator { */ -/* margin-top: 11px; */ -/* } */ - -/* #dock_item.shown.activated:hover #dock_item_main_container { */ -/* margin-top: -12px; */ -/* } */ -/**/ -/* #dock_item.shown.activated:hover #dock_item_indicator { */ -/* margin-top: 16px; */ -/* } */ -/**/ -/* #dock_item.shown.activated #dock_item_main_container { */ -/* margin-top: -4px; */ -/* } */ - -#dock_item.shown.activated #dock_item_icon { - opacity: 1; - /* background-color: #01458e; */ -} - -/* #dock_item.shown.activated #dock_item_indicator { */ -/* min-width: 4px; */ -/* margin-top: 8px; */ -/* background-color: #aac7ff; */ -/* } */ - -#dock_item_icon { - border-radius: 13px; - opacity: 0.7; - transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1); -} - -/* #dock_item_indicator { */ -/* transition: all 0.15s ease-out; */ -/* min-height: 4px; */ -/* border-radius: 4px; */ -/* } */ - -#dock_item { - transition: margin 0.25s cubic-bezier(0.25, 0.1, 0.25, 1); -} - -#dock_item.shown { - padding-left: 4px; - opacity: 1; -} - -#dock_item.shown:first-child { - padding-left: 0px; -} - -.dock_separator { - transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1); - min-width: 1.5px; - min-height: 50px; - margin: 0px 4px; - border-radius: 2px; - background-color: #2b5ea7; -} - -.dock_separator.hidden { - min-width: 0px; - background-color: transparent; - margin: 0px; -} - -/* #dock_item.shown:not(.activated) { */ -/* min-width: 0px; */ -/* min-height: 0px; */ -/* margin-top: 0px; */ -/* background-color: transparent; */ -/* } */ diff --git a/styles/launcher.css b/styles/launcher.css deleted file mode 100644 index 24382a4..0000000 --- a/styles/launcher.css +++ /dev/null @@ -1,230 +0,0 @@ -#launcher { - background-color: alpha(#000, 0.3); - padding: 0; - border-radius: 12px; - min-width: 640px; - border: 1px solid rgba(255, 255, 255, 0.1); -} - -/* #launcher-search { */ -/* color: #000; */ -/* } */ -#header_box { - padding: 0px 20px 0 20px; - color: #000; -} - -#close-button, -#config-button { - background-color: transparent; - border-radius: 6px; - padding: 6px; - transition: all 0.15s ease; -} - -#close-button:hover, -#close-button:focus, -#config-button:hover, -#config-button:focus { - background-color: rgba(255, 255, 255, 0.1); - border-radius: 6px; -} - -#close-button.focused, -#config-button.focused { - background-color: rgba(0, 122, 255, 0.2); - border-radius: 6px; - box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.4); -} - -#close-button.focused #close-label { - color: #007aff; -} - -#config-button.focused #config-label { - color: #007aff; -} - -#close-button:active { - background-color: rgba(255, 255, 255, 0.2); - border-radius: 6px; -} - -#close-label { - color: rgba(255, 255, 255, 0.7); - font-size: 18px; -} - -#close-button:active #close-label { - color: rgba(255, 255, 255, 0.9); -} - -#config-button:active { - background-color: rgba(255, 255, 255, 0.2); - border-radius: 6px; -} - -#config-label { - color: rgba(255, 255, 255, 0.7); - font-size: 18px; -} - -#config-button:active #config-label { - color: rgba(255, 255, 255, 0.9); -} - -#launcher-icon-label { - font-size: 20px; - padding: 6px; - color: rgba(255, 255, 255, 0.8); -} - -#launcher-search { - font-weight: 400; - font-size: 36px; - background-color: transparent; - color: rgba(255, 255, 255, 0.95); - border: none; - border-radius: 0; - padding: 12px 0; - margin: 0; -} - -#launcher-search:focus { - background-color: transparent; - box-shadow: none; - border: none; -} - -#launcher-search selection { - color: white; - background-color: rgba(0, 122, 255, 0.8); -} - -#launcher-results-scroll { - margin: 0; - border-radius: 0; - background: transparent; - padding: 0 20px 20px 20px; -} - -#launcher-results-scroll scrollbar { - border-radius: 0; - background-color: transparent; - padding: 0; - margin: 0; - min-width: 0; -} - -#launcher-results-scroll scrollbar slider { - border-radius: 2px; - min-width: 4px; - min-height: 20px; - background-color: rgba(255, 255, 255, 0.3); - margin: 0; -} - -#launcher-results-scroll scrollbar:hover slider { - background-color: rgba(255, 255, 255, 0.5); -} - -#launcher-results { - background: transparent; - margin-top: 8px; -} - -#launcher-result-item { - border-radius: 8px; - padding: 12px 16px; - margin: 2px 0; - min-height: 64px; - transition: all 0.15s ease; - background: transparent; -} - -@keyframes loadSlot { - 0% { - opacity: 0; - } - - 100% { - opacity: 1; - } -} - -#launcher-result-item:focus, -#launcher-result-item:selected, -#launcher-result-item:hover, -#launcher-result-item.selected { - border-radius: 8px; - background-color: rgba(0, 122, 255, 0.8); - padding: 12px 16px; - margin: 2px 0; -} - -#launcher-result-item.selected #result-item-title { - color: white; - font-weight: 600; -} - -#launcher-result-item.selected #result-item-subtitle { - color: rgba(255, 255, 255, 0.8); -} - -#launcher-result-item.selected #result-item-plugin { - color: rgba(255, 255, 255, 0.6); -} - -#result-item-main { - min-height: 56px; -} - -#launcher-result-item { - min-height: 56px; -} - -#result-item-icon { - min-width: 56px; - min-height: 56px; - margin-right: 16px; - border-radius: 12px; -} - -#result-item-title { - font-size: 18px; - font-weight: 500; - color: rgba(255, 255, 255, 0.95); - margin-top: 4px; - margin-bottom: 2px; -} - -#result-item-subtitle { - font-size: 14px; - color: rgba(255, 255, 255, 0.6); - margin-bottom: 4px; -} - -#result-item-plugin { - font-size: 12px; - color: rgba(255, 255, 255, 0.4); - font-style: normal; - margin-bottom: 4px; - opacity: 1; - font-weight: 400; -} - -#network-password-entry { - border: 1px solid rgba(255, 255, 255, 0.2); - background: rgba(255, 255, 255, 0.05); - color: rgba(255, 255, 255, 0.9); - padding: 12px; - border-radius: 8px; - margin-bottom: 8px; - font-size: 14px; -} - -#network-password-entry:focus { - border: 1px solid rgba(0, 122, 255, 0.6); - background: rgba(255, 255, 255, 0.1); - box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2); -} diff --git a/styles/lock.css b/styles/lock.css index 00fe279..930f614 100644 --- a/styles/lock.css +++ b/styles/lock.css @@ -50,6 +50,7 @@ #face-icon image { margin-bottom: 10px; + border-radius: 99px; } #face-icon { padding-bottom: 10px; diff --git a/styles/notification.css b/styles/notification.css index 35a7db0..04d4d46 100644 --- a/styles/notification.css +++ b/styles/notification.css @@ -34,7 +34,11 @@ color: var(--shadow); } -#notification-image image { +#notification-icon { + border-radius: 16px; +} + +#notification-image { border-radius: 16px; color: var(--on-surface); } diff --git a/styles/osd.css b/styles/osd.css index c4c2082..e69de29 100644 --- a/styles/osd.css +++ b/styles/osd.css @@ -1,38 +0,0 @@ -#osd { - background-color: alpha(#fff, 0.09); - padding: 12px 20px; - margin: 70px; - min-height: 200px; - border-radius: 16px; -} - -#osd scale { - min-width: 180px; -} - -#osd trough { - background: var(--surface); - min-height: 15px; - margin-right: 4px; - transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); - border-radius: 16px; -} - -#osd trough highlight { - border-radius: 100px; - background: var(--primary); - transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); -} - -#osd.muted trough highlight, -#osd.muted slider, -#osd scale.muted trough highlight, -#osd scale.muted slider { - background-color: var(--surface-bright); -} - -#brighntess-icons.muted, -#vol-icon.muted, -#mic-icon.muted { - color: var(--outline); -} diff --git a/styles/panel.css b/styles/panel.css index 218c358..62d97a1 100644 --- a/styles/panel.css +++ b/styles/panel.css @@ -1,147 +1,64 @@ #panel { - background-color: alpha(#fff, 0.07); - - /* border-bottom: 1px solid alpha(#010101, 0.025); */ - margin-top: -4px; - margin-bottom: -4px; - transition: all 120ms ease-in-out; -} - -#panel-icon { - font-size: 18px; -} -#global-title-button { - font-weight: bold; -} - -#panel-button { - margin: 0 4px 0 4px; - min-width: 20px; - min-height: 20px; -} - -#panel-button:hover { - background-color: alpha(#fff, 0.1); -} - -#menubar { - margin: 4px 0; -} - -#menubar label { - font-size: 13px; - /* font-weight: 400; */ -} -#battery-label { - font-weight: 500; - margin-right: 1px; -} -#battery-button { - padding-right: 3px; - padding-left: 3px; - border-radius: 8px; -} - -#battery-button:hover { - background-color: alpha(#fff, 0.1); -} - -#network-button { - padding-right: 3px; - padding-left: 3px; - border-radius: 8px; -} - -#network-button:hover { - background-color: alpha(#fff, 0.1); -} - -#bt-button { - padding-right: 3px; - padding-left: 3px; - border-radius: 8px; -} - -#bt-button:hover { - background-color: alpha(#fff, 0.1); -} - -#tray-button { - border-radius: 8px; - margin: 0 4px 0 0px; - min-width: 20px; - min-height: 20px; -} - -#tray-button:hover { - background-color: alpha(#fff, 0.1); -} - -#date-time { - margin: 0 10px; - font-weight: 500; + background-color: @bg; + margin: -4px 0; } #modules-left, #modules-right { margin: 0 5px; - padding: 3px 0; + padding: 2px 0; } -.button { - border-radius: 5px; - padding: 0 5px; - margin: 0 2.5px; - background: radial-gradient(alpha(#aaa, 0) 0%, transparent, transparent); - transition: all 100ms ease-in-out; +#panel-button:hover, +#battery-button:hover, +#network-button:hover, +#bt-button:hover, +#tray-button:hover, +#global-menu:hover, +#workspaces > button:hover { + background-color: @hover; } -.button:hover { - background: radial-gradient(alpha(#aaa, 0.2) 100%, transparent, transparent); -} - -#modus-button label { - font-size: 17px; - margin: 0 10px; -} - -#workspace-indicator { - margin: 0 4px; -} - -#workspaces label { - font-family: "SF Pro Rounded"; - color: white; /* fully transparent text */ -} -#workspaces > button { - padding-top: 0px; - padding-right: 16px; - font-family: "SF Pro Rounded"; - padding-left: 16px; - - margin: 6px 0px; - min-width: 12px; - border: 1px solid var(--outline); +#panel-button, +#battery-button, +#network-button, +#bt-button, +#tray-button { + margin: 5px 0; + padding: 0 2px; border-radius: 8px; } -#workspaces > button:hover { - background-color: alpha(#fff, 0.1); +#menubar label, +#battery-label, +#date-time { + font-weight: 500; +} +#global-menu { + margin: 5px 2px; + padding: 0 5px; + border-radius: 5px; +} +#date-time { + margin: 0 4px; +} + +#workspaces > button { + margin: 6px 0; + padding: 0 16px; + border-radius: 8px; + min-width: 12px; + border: 1px solid @border; } #workspaces > button.active { - background-color: alpha(#fff, 0.9); - /* font-weight: bold; */ + background-color: @active; } #workspaces > button.active label { - color: alpha(#000, 1); - font-family: "SF Pro Rounded"; -} -#workspaces > button.urgent { - background-color: alpha(var(--on-error), 0.7); + color: var(--shadow); } -#workspaces > button.empty { - background-color: transparent; +#workspaces > button.urgent { + background-color: @urgent; } diff --git a/styles/password-dialog.css b/styles/password-dialog.css new file mode 100644 index 0000000..6223027 --- /dev/null +++ b/styles/password-dialog.css @@ -0,0 +1,132 @@ +#wifi-password-dialog { + background-color: transparent; +} + +#wifi-dialog-background { + background-color: alpha(#fff, 0.05); + border-radius: 12px; + border: 1px solid rgba(255, 255, 255, 0.1); + padding: 20px; + min-width: 450px; +} + +#wifi-dialog-title-container { + /* margin-bottom: 12px; */ +} + +#wifi-dialog-icon { + color: #007aff; + margin-right: 4px; +} + +#wifi-dialog-title { + color: #ffffff; + font-size: 14px; + font-weight: 500; +} + +#wifi-dialog-error { + color: #ff4444; + font-size: 12px; + font-weight: 500; + /* margin-bottom: 8px; */ +} + +#wifi-dialog-password-container { + margin: 5px 0; +} + +#wifi-dialog-password-label { + color: #ffffff; + font-size: 13px; + font-weight: 500; + margin-bottom: 4px; +} + +#wifi-dialog-password-entry { + background-color: rgba(255, 255, 255, 0.1); + border: 1px solid rgba(255, 255, 255, 0.2); + border-radius: 6px; + padding: 8px 12px; + color: #ffffff; + font-size: 13px; +} + +#wifi-dialog-password-entry:focus { + border-color: #007aff; + box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3); + background-color: rgba(255, 255, 255, 0.15); +} + +#wifi-dialog-show-password-box { + margin-top: 4px; +} + +#wifi-dialog-show-password-button { + background-color: transparent; + border: none; + padding: 4px; + border-radius: 4px; + min-width: 24px; + min-height: 24px; +} + +#wifi-dialog-show-password-button:hover { + background-color: alpha(#fff, 0.1); +} + +#wifi-dialog-show-password-button image { + color: #ffffff; +} + +#wifi-dialog-show-password-label { + color: #ffffff; + font-size: 12px; +} + +#wifi-dialog-button-box { + margin-top: -15px; +} + +#wifi-dialog-cancel-button, +#wifi-dialog-join-button { + border-radius: 6px; + font-size: 13px; + font-weight: 500; + min-width: 80px; + min-height: 30px; +} + +#wifi-dialog-cancel-button { + background-color: rgba(255, 255, 255, 0.1); + border: 1px solid rgba(255, 255, 255, 0.2); + color: #ffffff; +} + +#wifi-dialog-cancel-button:hover { + background-color: rgba(255, 255, 255, 0.15); +} + +#wifi-dialog-join-button { + background-color: #007aff; + border: 1px solid #007aff; + color: #ffffff; +} + +#wifi-dialog-join-button:hover { + background-color: #0056cc; + border-color: #0056cc; +} + +#wifi-dialog-join-button.disabled { + opacity: 0.5; + background-color: #555555; + border-color: #555555; + color: #aaaaaa; +} + +#wifi-dialog-join-button.disabled:hover { + background-color: #555555; + border-color: #555555; + color: #aaaaaa; +} diff --git a/styles/player.css b/styles/player.css index 1a9b651..437084b 100644 --- a/styles/player.css +++ b/styles/player.css @@ -40,7 +40,7 @@ } #outer-no-player-box-c { min-height: 55px; - min-width: 310px; + min-width: 345px; border-radius: 8px; /* margin: 0 6px; */ /* background-color: alpha(#000, 0.3); */ diff --git a/styles/switcher.css b/styles/switcher.css index 5302281..e69de29 100644 --- a/styles/switcher.css +++ b/styles/switcher.css @@ -1,38 +0,0 @@ -#application-switcher-container { - background: var(--shadow); - border-radius: 16px; -} - -#application-switcher-view { - min-height: 120px; - padding: 4px; -} - -#switcher-button { - padding: 4px; - min-width: 100px; -} - -#window-button { - background-color: var(--surface); - border-radius: 4px; -} - -#switcher-button:hover { - background-color: var(--surface); -} - -#window-button.active { - background-color: var(--surface-bright); - border: 3px solid var(--surface-bright); -} - -#switcher-button label { - color: var(--foreground); - font-size: 10px; - margin-top: 4px; -} - -#window-row { - padding: 18px; -} diff --git a/styles/todo.css b/styles/todo.css index a65ddf4..e69de29 100644 --- a/styles/todo.css +++ b/styles/todo.css @@ -1,258 +0,0 @@ -/* Todo List Styles - matching control center design */ - -#todo-list-window { - /* background-color: alpha(#fff, 0.05); */ - border-radius: 12px; - box-shadow: none; - margin: 0; -} - -#todo-main-container { - box-shadow: inset 0 0 0 1px alpha(#aaa, 0.4); - border-radius: 12px; - padding: 12px; /* Increased padding */ - min-height: 500px; /* Ensure minimum height */ - min-width: 350px; /* Ensure minimum width */ -} - -#todo-header { - margin-bottom: 8px; -} - -#todo-title { - font-size: 16px; - font-family: "SF Pro Rounded"; - font-weight: bold; - color: #ffffff; -} - -#todo-stats { - font-size: 12px; - font-weight: 500; - color: #999; - margin-top: -2px; -} - -/* Add new todo section */ -#todo-add-section { - box-shadow: inset 0 0 0 0.5px alpha(#aaa, 0.4); - border: 1px solid alpha(#111, 0.4); - border-radius: 12px; - padding: 1rem; - margin-bottom: 8px; - min-height: 40px; /* Ensure minimum height */ -} - -#new-todo-entry { - background-color: rgba(255, 255, 255, 0.1); - border: 1px solid rgba(255, 255, 255, 0.2); - border-radius: 6px; - padding: 8px 12px; - color: #ffffff; - font-size: 13px; - font-family: "SF Pro Rounded"; -} - -#new-todo-entry:focus { - border-color: #007aff; - box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3); - background-color: rgba(255, 255, 255, 0.15); -} - -#add-todo-button { - /* background-color: #007aff; */ - /* border: 1px solid #007aff; */ - border-radius: 6px; - min-width: 20px; - min-height: 12px; - color: #ffffff; - font-size: 16px; -} - -#add-todo-button:hover { - /* background-color: #0056cc; */ - /* border-color: #0056cc; */ -} - -/* Todo items container */ -#todos-scrolled { - background-color: transparent; - min-height: 200px; /* Minimum height for content */ -} - -#todos-container { - padding: 4px; -} - -/* Individual todo items */ -#todo-item { - background-color: alpha(#000, 0.2); /* More visible background */ - border: 1px solid alpha(#111, 0.4); - border-radius: 12px; - padding: 12px; - margin: 4px 0; - min-height: 40px; /* Ensure minimum height */ - transition: background-color 0.2s ease; -} - -#todo-item:hover { - background-color: alpha(#fff, 0.12); -} - -/* Todo item controls */ -#todo-checkbox { - background-color: transparent; - border-radius: 50%; /* Circular appearance */ - min-width: 20px; - min-height: 20px; - margin-right: 8px; -} - -#todo-checkbox:hover { - border-color: #007aff; -} - -/* SVG icon styling for checkboxes and buttons */ -#todo-checkbox-icon { - color: #007aff; -} - -#todo-edit-icon, -#todo-delete-icon, -#add-todo-icon { - color: #ffffff; - opacity: 0.8; -} - -#todo-edit-icon:hover, -#todo-delete-icon:hover, -#add-todo-icon:hover { - opacity: 1; -} - -#todo-text { - font-size: 13px; - font-weight: 400; - color: #ffffff; - font-family: "SF Pro Rounded"; -} - -#todo-date { - font-size: 10px; - font-weight: 400; - color: #999999; - font-family: "SF Pro Rounded"; - margin-top: 2px; - opacity: 0.8; -} - -.todo-date-text { - color: #999999; - font-size: 10px; -} - -#todo-text-entry { - background-color: rgba(255, 255, 255, 0.1); - border: 1px solid rgba(255, 255, 255, 0.2); - border-radius: 4px; - padding: 4px 8px; - color: #ffffff; - font-size: 14px; - font-family: "SF Pro Rounded"; -} - -#todo-text-entry:focus { - border-color: #007aff; - box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.3); - background-color: rgba(255, 255, 255, 0.15); -} - -/* Priority, edit, delete buttons */ -#todo-priority, -#todo-edit, -#todo-delete { - background-color: transparent; - border: none; - border-radius: 4px; - min-width: 20px; - min-height: 20px; - margin: 0 2px; - transition: background-color 0.2s ease; -} - -#todo-priority:hover, -#todo-edit:hover, -#todo-delete:hover { - background-color: alpha(#fff, 0.1); -} - -#todo-priority-label, -#todo-edit-label, -#todo-delete-label { - font-size: 12px; -} - -/* Clear completed button */ -#clear-completed-button { - background-color: alpha(#fff, 0.1); - border: 1px solid alpha(#999, 0.3); - border-radius: 8px; - padding: 8px 16px; - color: #999; - font-size: 12px; - font-weight: 500; - font-family: "SF Pro Rounded"; - margin-top: 8px; - transition: background-color 0.2s ease; -} - -#clear-completed-button:hover { - background-color: alpha(#fff, 0.15); - color: #ffffff; -} - -/* Completed todos styling */ -#todo-item.completed { - opacity: 0.6; -} - -#todo-item.completed #todo-text { - text-decoration: line-through; - color: #999; -} - -/* Priority styling */ -.priority-high #todo-priority-label { - color: #ff4444; -} - -.priority-medium #todo-priority-label { - color: #ffaa00; -} - -.priority-low #todo-priority-label { - color: #44ff44; -} - -/* Scrollbar styling to match control center */ -#todos-scrolled scrollbar { - background-color: transparent; - border-radius: 8px; - margin: 2px; - min-width: 8px; -} - -#todos-scrolled scrollbar slider { - background-color: alpha(#fff, 0.3); - border-radius: 4px; - min-width: 6px; - margin: 1px; -} - -#todos-scrolled scrollbar slider:hover { - background-color: alpha(#fff, 0.5); -} - -#todos-scrolled scrollbar slider:active { - background-color: alpha(#fff, 0.7); -} diff --git a/widgets/about.py b/widgets/about.py new file mode 100644 index 0000000..e87766d --- /dev/null +++ b/widgets/about.py @@ -0,0 +1,541 @@ +import re +import subprocess + +from fabric.utils import GdkPixbuf, Gtk, get_relative_path, os + +from utils.functions import escape_markup_text +from utils.icon_resolver import IconResolver +from utils.utils import setup_cursor_hover + + +def read_dmi(field): + try: + with open(f"/sys/class/dmi/id/{field}") as f: + return f.read().strip() + except Exception: + return "Unknown" + + +def get_gpu_name(): + try: + output = ( + subprocess.check_output( + "lspci -nn | grep -i 'VGA compatible controller'", shell=True, text=True + ) + .strip() + .split("\n") + ) + + def clean(line): + matches = re.findall(r"\[(.*?)\]", line) + if len(matches) >= 2: + return matches[1].strip() + desc = line.split(":", 2)[-1] + return desc.replace("Corporation", "").strip() + + for line in output: + if any(vendor in line.lower() for vendor in ["nvidia", "amd", "radeon"]): + return clean(line) + + if output: + return clean(output[0]) + + return "Unknown GPU" + except Exception: + return "Unknown GPU" + + +def get_executable_path(exec_string): + """Extract and find the actual executable path from Exec field""" + if not exec_string: + return None + + # Remove common exec modifiers and arguments + exec_parts = exec_string.split() + if not exec_parts: + return None + + executable = exec_parts[0] + + # Remove common prefixes + prefixes_to_remove = ["env", "bash", "sh", "/usr/bin/env"] + while executable in prefixes_to_remove and len(exec_parts) > 1: + exec_parts.pop(0) + executable = exec_parts[0] + + # If it's already an absolute path, check if it exists + if executable.startswith("/"): + if os.path.exists(executable): + return executable + return None + + # Search in PATH + try: + result = subprocess.run(["which", executable], capture_output=True, text=True) + if result.returncode == 0: + return result.stdout.strip() + except Exception: + pass + + return None + + +def get_app_info(wmclass): + """Get comprehensive application information from .desktop file""" + if not wmclass: + return { + "name": "Desktop", + "version": "", + "comment": "Desktop Environment", + "icon": "desktop", + "exec": "", + "location": "", + "categories": "", + "desktop_file": "", + } + + desktop_paths = [ + "/usr/share/applications", + "/var/lib/flatpak/exports/share/applications", + os.path.expanduser("~/.local/share/applications"), + "/usr/local/share/applications", + ] + + for path in desktop_paths: + if not os.path.exists(path): + continue + + # Try exact match first + exact_matches = [ + f for f in os.listdir(path) if f.lower() == f"{wmclass.lower()}.desktop" + ] + + # Then try starts with + startswith_matches = [ + f + for f in os.listdir(path) + if f.startswith(wmclass.lower()) and f.endswith(".desktop") + ] + + # Finally try contains + contains_matches = [ + f + for f in os.listdir(path) + if wmclass.lower() in f.lower() and f.endswith(".desktop") + ] + + # Process matches in order of preference + for matches in [exact_matches, startswith_matches, contains_matches]: + for filename in matches: + desktop_file = os.path.join(path, filename) + try: + with open(desktop_file, "r", encoding="utf-8") as f: + content = f.read() + + name = wmclass.title() + version = "" + comment = "" + icon = wmclass.lower() + exec_cmd = "" + categories = "" + + # Parse desktop file + in_desktop_entry = False + for line in content.split("\n"): + line = line.strip() + if line == "[Desktop Entry]": + in_desktop_entry = True + continue + elif line.startswith("[") and line.endswith("]"): + in_desktop_entry = False + continue + + if not in_desktop_entry or "=" not in line: + continue + + key, value = line.split("=", 1) + if key == "Name": + name = value + elif key == "Version": + version = value + elif key == "Comment": + comment = value + elif key == "GenericName" and not comment: + # Use GenericName as fallback description + comment = value + elif key == "Icon": + icon = value + elif key == "Exec": + exec_cmd = value + elif key == "Categories": + categories = value + + # Get executable location + location = get_executable_path(exec_cmd) + + return { + "name": name, + "version": version, + "comment": comment, + "icon": icon, + "exec": exec_cmd, + "location": location or "", + "categories": categories, + "desktop_file": desktop_file, + } + except Exception: + continue + + # Fallback: try to find executable in PATH + location = "" + try: + result = subprocess.run( + ["which", wmclass.lower()], capture_output=True, text=True + ) + if result.returncode == 0: + location = result.stdout.strip() + except Exception: + pass + + return { + "name": wmclass.title() if wmclass else "Unknown Application", + "version": "", + "comment": "", + "icon": wmclass.lower() if wmclass else "application-x-executable", + "exec": "", + "location": location, + "categories": "", + "desktop_file": "", + } + + +class AboutApp(Gtk.Window): + def __init__(self, app_name="Unknown Application", wmclass=""): + super().__init__(title=f"About {app_name}") + self.app_name = app_name + self.wmclass = wmclass + self.icon_resolver = IconResolver() + + self.set_default_size(300, 500) + self.set_size_request(300, 480) + self.set_resizable(False) + self.set_title(f"About {app_name}") + self.set_name("about-app") + self.set_visible(False) + + self.setup_ui() + + def setup_ui(self): + app_info = get_app_info(self.wmclass) + + main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) + main_box.set_margin_top(20) + main_box.set_margin_bottom(20) + main_box.set_margin_start(15) + main_box.set_margin_end(15) + + # App Icon + logo_box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER) + try: + # Use IconResolver's get_icon_pixbuf method like other parts of the project + icon_pixbuf = self.icon_resolver.get_icon_pixbuf(app_info["icon"], 128) + if icon_pixbuf: + logo = Gtk.Image.new_from_pixbuf(icon_pixbuf) + else: + raise Exception("Icon pixbuf not found") + except Exception: + # Fallback: try direct file path if it's an absolute path + try: + if app_info["icon"].startswith("/") and os.path.exists( + app_info["icon"] + ): + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( + app_info["icon"], 128, 128, preserve_aspect_ratio=True + ) + logo = Gtk.Image.new_from_pixbuf(pixbuf) + else: + raise Exception("Direct path failed") + except Exception: + # Final fallback: emoji + logo = Gtk.Label() + logo.set_markup("📱") + + logo_box.pack_start(logo, False, False, 0) + logo_box.set_margin_bottom(15) + + # App Name + app_name_label = Gtk.Label() + app_name_label.set_markup( + f"{escape_markup_text(app_info['name'])}" + ) + app_name_label.set_halign(Gtk.Align.CENTER) + app_name_label.set_margin_bottom(5) + + # Version (if available) + if app_info["version"]: + version_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + version_label = Gtk.Label( + label=f"Version {app_info.get('version', 'Unknown')}" + ) + version_label.set_name("version-label") + version_label.set_halign(Gtk.Align.CENTER) + version_box.pack_start(version_label, False, False, 0) + version_box.set_margin_bottom(5) + + # Description/Comment - Make it more prominent + description_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + if app_info["comment"]: + # Create a frame for the description to make it stand out + desc_frame = Gtk.Frame() + desc_frame.set_shadow_type(Gtk.ShadowType.IN) + + description_label = Gtk.Label() + description_label.set_markup( + f"{escape_markup_text(app_info['comment'])}" + ) + description_label.set_justify(Gtk.Justification.CENTER) + description_label.set_halign(Gtk.Align.CENTER) + description_label.set_line_wrap(True) + description_label.set_max_width_chars(45) + description_label.set_margin_top(8) + description_label.set_margin_bottom(8) + description_label.set_margin_start(12) + description_label.set_margin_end(12) + + desc_frame.add(description_label) + description_box.pack_start(desc_frame, False, False, 0) + else: + # Show a placeholder if no description is available + placeholder_label = Gtk.Label() + placeholder_label.set_markup( + "No description available" + ) + placeholder_label.set_halign(Gtk.Align.CENTER) + description_box.pack_start(placeholder_label, False, False, 0) + + description_box.set_margin_bottom(15) + + # Information Grid + # Create a label with markup + info_frame = Gtk.Frame() + label = Gtk.Label() + label.set_markup("Application Information") + label.set_margin_bottom(5) + info_frame.set_label_widget(label) + + info_frame.set_label_align(0.5, 0.5) + + info_grid = Gtk.Grid() + info_grid.set_row_spacing(8) + info_grid.set_column_spacing(15) + info_grid.set_margin_top(10) + info_grid.set_margin_bottom(10) + info_grid.set_margin_start(15) + info_grid.set_margin_end(15) + info_grid.set_valign(Gtk.Align.CENTER) + info_grid.set_halign(Gtk.Align.CENTER) + + def make_info_row(label_text, value_text, row): + """Create a row in the info grid""" + label = Gtk.Label(label=f"{label_text}:") + label.set_halign(Gtk.Align.END) + label.set_markup(f"{label_text}:") + + value = Gtk.Label() + value.set_markup( + f"{ + escape_markup_text(str(value_text)) + }" + ) + value.set_halign(Gtk.Align.START) + value.set_line_wrap(True) + value.set_max_width_chars(30) + value.set_name("info-value-label") + + info_grid.attach(label, 0, row, 1, 1) + info_grid.attach(value, 1, row, 1, 1) + + row = 0 + + # Application Name + make_info_row("Name", app_info["name"], row) + row += 1 + + # Version + if app_info["version"]: + make_info_row("Version", app_info["version"], row) + row += 1 + + # Executable Location + if app_info["location"]: + make_info_row("Location", app_info["location"], row) + row += 1 + + # Window Class + if self.wmclass: + make_info_row("Window Class", self.wmclass, row) + row += 1 + + # Categories + if app_info["categories"]: + categories = app_info["categories"].replace(";", ", ").strip(", ") + make_info_row("Categories", categories, row) + row += 1 + + # Desktop File + if app_info["desktop_file"]: + desktop_file_name = os.path.basename(app_info["desktop_file"]) + make_info_row("Desktop File", desktop_file_name, row) + row += 1 + + info_frame.add(info_grid) + + # Layout + main_box.pack_start(logo_box, False, False, 0) + main_box.pack_start(app_name_label, False, False, 0) + if app_info["version"]: + main_box.pack_start(version_box, False, False, 0) + main_box.pack_start(description_box, False, False, 0) + main_box.pack_start(info_frame, False, False, 0) + + self.add(main_box) + + def toggle(self, b): + if self.get_visible(): + self.hide() + else: + self.show_all() + + +class About(Gtk.Window): + def __init__(self): + super().__init__(title="About Menu") + self.set_default_size(300, 550) + self.set_size_request(300, 500) + self.set_resizable(False) + self.set_title("About PC") + self.set_name("about-menu") + self.set_visible(False) + + main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) + main_box.set_margin_top(10) + main_box.set_margin_bottom(20) + main_box.set_margin_start(20) + main_box.set_margin_end(20) + + # Logo + logo_box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER) + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( + get_relative_path("../assets/icons/misc/imac.svg"), + 158, + 108, + preserve_aspect_ratio=True, + ) + logo = Gtk.Image.new_from_pixbuf(pixbuf) + logo_box.pack_start(logo, False, False, 0) + logo_box.set_margin_top(60) + + # Product Name & Vendor + name_label = Gtk.Label() + name_label.set_margin_top(30) + name_label.set_markup( + f"{ + escape_markup_text(read_dmi('product_name')) + }" + ) + + vendor_label = Gtk.Label(label=read_dmi("sys_vendor")) + vendor_label.set_name("vendor-label") + vendor_label.set_halign(Gtk.Align.CENTER) + + # Info Grid + info_grid = Gtk.Grid() + info_grid.set_row_spacing(6) + info_grid.set_column_spacing(10) + info_grid.set_valign(Gtk.Align.CENTER) + info_grid.set_halign(Gtk.Align.FILL) + + def make_label(text, align_end=False, name=None): + label = Gtk.Label(label=text) + label.set_halign(Gtk.Align.END if align_end else Gtk.Align.START) + if name: + label.set_name(name) + return label + + # Info values + labels = [ + ( + "Kernel", + subprocess.run( + "uname -r", shell=True, capture_output=True, text=True + ).stdout.strip(), + ), + ( + "CPU", + subprocess.run( + "lscpu | grep 'Model name:' | cut -d ':' -f2-", + shell=True, + capture_output=True, + text=True, + ).stdout.strip(), + ), + ( + "Memory", + subprocess.run( + "free -h --giga | grep Mem | tr -s ' ' | cut -d ' ' -f 2", + shell=True, + capture_output=True, + text=True, + ).stdout.strip(), + ), + ("GPU", get_gpu_name()), + ( + "Uptime", + subprocess.run( + "uptime -p", shell=True, capture_output=True, text=True + ).stdout.strip(), + ), + ] + + for i, (title, value) in enumerate(labels): + title_label = make_label(title, align_end=True) + value_label = make_label(value, align_end=False, name="info-label") + info_grid.attach(title_label, 0, i, 1, 1) + info_grid.attach(value_label, 1, i, 1, 1) + + # Button + button_box = Gtk.Box(halign=Gtk.Align.CENTER) + button_box.set_margin_top(20) + more_info_button = Gtk.Button(label="More Info...", name="more-info-button") + setup_cursor_hover(more_info_button, "pointer") + more_info_button.connect("clicked", self.open_more_info) + button_box.pack_start(more_info_button, False, False, 0) + + # Info Footer + info = Gtk.Label( + label="™ and © 2025 Linux Inc.\nAll rights reserved.\n\n", + justify=Gtk.Justification.CENTER, + halign=Gtk.Align.CENTER, + ) + info.set_name("info-label") + info.set_margin_top(10) + + # Layout Order + main_box.pack_start(logo_box, False, False, 0) + main_box.pack_start(name_label, False, False, 0) + main_box.pack_start(vendor_label, False, False, 0) + main_box.pack_start(info_grid, False, False, 0) + main_box.pack_start(button_box, False, False, 0) + main_box.pack_start(info, False, False, 0) + + self.add(main_box) + + def open_more_info(self, button): + # TODO: Implement the logic to open more information + pass + + def toggle(self, b): + if self.get_visible(): + self.hide() + else: + self.show_all() diff --git a/widgets/battery_widget.py b/widgets/battery_widget.py new file mode 100644 index 0000000..8fe05fc --- /dev/null +++ b/widgets/battery_widget.py @@ -0,0 +1,387 @@ +from fabric.utils import GLib +from fabric.widgets.box import Box +from fabric.widgets.button import Button +from fabric.widgets.centerbox import CenterBox +from fabric.widgets.image import Image +from fabric.widgets.label import Label +from fabric.widgets.separator import Separator +from utils.gamemode import check_gamemode, toggle_gamemode + +from services.battery import BatteryService, DeviceState +from utils.functions import clear_children, format_duration +from utils.utils import svg_file + + +class EnergyModeButton(Box): + def __init__( + self, + profile_name: str, + display_name: str, + icon_name: str, + battery_service: BatteryService, + parent, + **kwargs, + ): + super().__init__(name="energy-mode-button", **kwargs) + self.profile_name = profile_name + self.battery_service = battery_service + self.parent = parent + + self.mode_icon_svg = svg_file(f"power_modes/battery-{icon_name}.svg", size=24) + + self.mode_icon = Box( + children=[self.mode_icon_svg], + name="energy-mode-icon", + style_classes="battery-profile-icon", + ) + + self.mode_label = Label( + label=display_name, + style_classes="battery-power-mode", + h_align="start", + h_expand=True, + ) + + start_box = Box( + orientation="horizontal", + spacing=4, + children=[self.mode_icon, self.mode_label], + ) + + self.button = Button( + child=start_box, + h_expand=True, + name="energy-mode-button-clickable", + on_clicked=self.on_clicked, + style_classes="battery-profile-button", + ) + + self.children = [self.button] + self.update_state() + + def on_clicked(self, *args): + success = self.battery_service.set_power_profile(self.profile_name) + if success: + # Update all profile buttons in parent + self.parent.update_energy_mode_buttons() + + # Reset icon state after short delay + GLib.timeout_add(300, lambda: self._reset_icon_state()) + + def _reset_icon_state(self): + return False # Remove timeout + + def update_state(self): + current_profile = self.battery_service.get_power_profile() + is_active = current_profile == self.profile_name + if is_active: + self.mode_icon.add_style_class("connected") + else: + self.mode_icon.remove_style_class("connected") + + +class GameModeButton(Box): + def __init__(self, parent, **kwargs): + super().__init__(name="energy-mode-button", h_expand=True, **kwargs) + self.parent = parent + + self.game_icon = Image( + icon_name="applications-games-symbolic", + size=16, + name="game-mode-icon", + style_classes="battery-gamemode-icon", + ) + + self.game_label = Label( + label="Game Mode", + style_classes="gamemode-button", + h_align="start", + h_expand=True, + ) + + start_box = Box( + orientation="horizontal", + spacing=3, + children=[self.game_icon, self.game_label], + ) + + self.button = Button( + child=start_box, + name="game-mode-button-clickable", + on_clicked=self.on_clicked, + h_expand=True, + style_classes="battery-gamemode-button", + ) + + self.children = [self.button] + self.update_state() + + def on_clicked(self, *args): + try: + toggle_gamemode() + GLib.timeout_add(500, lambda: self.update_state()) + except Exception as e: + print(f"Failed to toggle game mode: {e}") + + GLib.timeout_add(300, lambda: self._reset_icon_state()) + + def _reset_icon_state(self): + return False # Remove timeout + + def update_state(self): + try: + is_active = check_gamemode() == "t" + if is_active: + self.game_icon.add_style_class("connected") + else: + self.game_icon.remove_style_class("connected") + except Exception as e: + print(f"Failed to check game mode status: {e}") + self.game_icon.remove_style_class("connected") + + return False # Remove timeout if called from GLib.timeout_add + + +class BatteryControl(Box): + def __init__(self, parent, **kwargs): + super().__init__( + spacing=12, + orientation="vertical", + name="control-center-widgets", + **kwargs, + ) + self.set_size_request(354, -1) + + self.parent = parent + self.battery_service = BatteryService() + self.energy_mode_buttons = [] + + self.battery_widget = Box( + name="battery-widget", + orientation="vertical", + style_classes="battery-status-section", + h_expand=True, + spacing=8, + ) + + self.battery_title = Label( + label="Battery", style_classes="battery-main-title", h_align="start" + ) + + self.battery_percentage_label = Label( + label="80%", style_classes="battery-percentage", h_align="end" + ) + + self.battery_header = CenterBox( + start_children=self.battery_title, + end_children=self.battery_percentage_label, + name="battery-header", + ) + + self.power_source_label = Label( + label="Power Source: Power Adapter", + style_classes="battery-power-source", + h_align="start", + ) + + self.charging_time_label = Label( + label="1h 4m until fully charged", + style_classes="battery-power-source", + h_align="start", + ) + + self.energy_mode_section = Box( + orientation="vertical", spacing=8, name="energy-mode-section" + ) + + self.energy_mode_title = Label( + label="Energy Mode", style_classes="battery-section-title", h_align="start" + ) + + self.energy_modes_container = Box( + orientation="vertical", spacing=4, name="energy-modes-container" + ) + + self.game_mode_section = Box( + orientation="vertical", spacing=8, name="game-mode-section" + ) + + self.game_mode_title = Label( + label="Game Mode", style_classes="battery-section-title", h_align="start" + ) + + self.game_mode_container = Box( + orientation="vertical", spacing=4, name="game-mode-container" + ) + + self.battery_settings_button = Button( + v_align="center", + child=Label( + label="Battery Settings", + h_align="start", + ), + style_classes="battery-settings-button", + on_clicked=self.open_battery_settings, + ) + + self.battery_widget.add(self.battery_header) + self.battery_widget.add(self.power_source_label) + self.battery_widget.add(self.charging_time_label) + + separator1 = Separator(orientation="h", name="separator") + self.battery_widget.add(separator1) + + self.energy_mode_section.add(self.energy_mode_title) + self.energy_mode_section.add(self.energy_modes_container) + self.battery_widget.add(self.energy_mode_section) + + separator2 = Separator(orientation="h", name="separator") + self.battery_widget.add(separator2) + + self.game_mode_section.add(self.game_mode_title) + self.game_mode_section.add(self.game_mode_container) + self.battery_widget.add(self.game_mode_section) + + separator3 = Separator(orientation="h", name="separator") + self.battery_widget.add(separator3) + + self.battery_widget.add(self.battery_settings_button) + + self.add(self.battery_widget) + + self.battery_service.connect("changed", self.on_battery_changed) + self.battery_service.connect("power_profile_changed", self.on_profile_changed) + + # Initialize display + self.update_battery_info() + self.create_energy_mode_buttons() + self.create_game_mode_button() + + def open_battery_settings(self, *args): + # TODO: Implement to open Battery Settings + pass + + def create_energy_mode_buttons(self): + # Clear existing buttons + for button in self.energy_mode_buttons: + button.destroy() + self.energy_mode_buttons.clear() + + # Get available profiles + available_profiles = self.battery_service.get_available_power_profiles() or [] + + if not available_profiles: + no_profiles_label = Label( + label="No energy modes available", + style_classes="battery-no-profiles", + h_align="start", + ) + self.energy_modes_container.add(no_profiles_label) + return + + # Define energy mode mappings with proper icon names + energy_mode_config = { + "balanced": {"display": "Automatic", "icon": "balanced"}, + "power-saver": {"display": "Low Power", "icon": "power"}, + "powersave": {"display": "Low Power", "icon": "power"}, + "performance": {"display": "High Power", "icon": "performance"}, + } + + # Define the desired order for energy modes + desired_order = ["balanced", "power-saver", "powersave", "performance"] + + # Create ordered list of available profiles + ordered_profiles = [] + for profile_name in desired_order: + if profile_name in available_profiles: + ordered_profiles.append(profile_name) + + # Add any remaining profiles not in the desired order + for profile in available_profiles: + if profile not in ordered_profiles: + ordered_profiles.append(profile) + + # Create button for each available profile in the specified order + for profile in ordered_profiles: + config = energy_mode_config.get( + profile, {"display": profile.title(), "icon": "good"} + ) + + button = EnergyModeButton( + profile_name=profile, + display_name=config["display"], + icon_name=config["icon"], + battery_service=self.battery_service, + parent=self, + ) + self.energy_mode_buttons.append(button) + self.energy_modes_container.add(button) + + def update_energy_mode_buttons(self): + for button in self.energy_mode_buttons: + button.update_state() + + def create_game_mode_button(self): + # Clear existing game mode button if any + clear_children(self.game_mode_container) + + # Create game mode button + self.game_mode_button = GameModeButton(parent=self) + self.game_mode_container.add(self.game_mode_button) + + def _format_time(self, seconds: int) -> str: + return format_duration(seconds) + + def update_battery_info(self): + is_present = bool(self.battery_service.get_property("IsPresent")) + if not is_present: + self.battery_percentage_label.set_label("No Battery") + self.power_source_label.set_label("Power Source: Not Present") + self.charging_time_label.set_label("") + return + + # Update percentage in header + percentage = int(self.battery_service.get_property("Percentage") or 0) + self.battery_percentage_label.set_label(f"{percentage}%") + + # Update power source and charging info + state_code = self.battery_service.get_property("State") + state = DeviceState.get(state_code, "UNKNOWN") + + if state in ["CHARGING", "PENDING_CHARGE"]: + self.power_source_label.set_label("Power Source: Power Adapter") + seconds_to_full = int(self.battery_service.get_property("TimeToFull") or 0) + time_to_full = self._format_time(seconds_to_full) + if time_to_full != "N/A" and time_to_full != "0m": + self.charging_time_label.set_label( + f"{time_to_full} until fully charged" + ) + else: + self.charging_time_label.set_label("Charging...") + elif state == "FULLY_CHARGED": + self.power_source_label.set_label("Power Source: Power Adapter") + self.charging_time_label.set_label("Fully Charged") + elif state in ["DISCHARGING", "PENDING_DISCHARGE"]: + self.power_source_label.set_label("Power Source: Battery") + seconds_to_empty = int( + self.battery_service.get_property("TimeToEmpty") or 0 + ) + time_to_empty = self._format_time(seconds_to_empty) + if time_to_empty != "N/A" and not time_to_empty.startswith( + "4553h" + ): # Filter out unrealistic times + self.charging_time_label.set_label(f"{time_to_empty} remaining") + else: + self.charging_time_label.set_label("On Battery Power") + elif state == "EMPTY": + self.power_source_label.set_label("Power Source: Battery") + self.charging_time_label.set_label("Battery Empty") + else: + self.power_source_label.set_label("Power Source: Unknown") + self.charging_time_label.set_label("") + + def on_battery_changed(self, *args): + self.update_battery_info() + + def on_profile_changed(self, service, *args): + self.update_energy_mode_buttons() diff --git a/widgets/clipping_box.py b/widgets/clipping_box.py new file mode 100644 index 0000000..dc14306 --- /dev/null +++ b/widgets/clipping_box.py @@ -0,0 +1,46 @@ +import math +from typing import cast + +import cairo +from fabric.widgets.box import Box + + +class ClippingBox(Box): + """A regular `Box` that replicates the CSS behaviour of `overflow: hidden` because GTK failed at it. + + NOTE: use instead of the old `CustomImage` snippet. + """ + + @staticmethod + def render_shape(cr: cairo.Context, width: int, height: int, radius: int = 0): + cr.move_to(radius, 0) + cr.line_to(width - radius, 0) + cr.arc(width - radius, radius, radius, -(math.pi / 2), 0) + cr.line_to(width, height - radius) + cr.arc(width - radius, height - radius, radius, 0, (math.pi / 2)) + cr.line_to(radius, height) + cr.arc(radius, height - radius, radius, (math.pi / 2), math.pi) + cr.line_to(0, radius) + cr.arc(radius, radius, radius, math.pi, (3 * (math.pi / 2))) + + return cr.close_path() + + def do_draw(self, cr: cairo.Context): + cr.save() + ClippingBox.render_shape( + cr, + self.get_allocated_width(), + self.get_allocated_height(), + cast( + int, + self.get_style_context().get_property( + "border-radius", self.get_state_flags() + ), + ), + ) + cr.clip() + + Box.do_draw(self, cr) + + cr.restore() + return True diff --git a/widgets/mousecapture.py b/widgets/mousecapture.py index af432fc..03f3f1f 100644 --- a/widgets/mousecapture.py +++ b/widgets/mousecapture.py @@ -1,12 +1,13 @@ from typing import Any import cairo -from gi.repository import GLib, GtkLayerShell # type: ignore - +from fabric.utils import GLib from fabric.widgets.eventbox import EventBox +from fabric.widgets.wayland import WaylandWindow as Window from fabric.widgets.widget import Widget +from gi.repository import GtkLayerShell # type: ignore + from utils.roam import modus_service -from widgets.wayland import WaylandWindow as Window class MouseCapture(Window): diff --git a/widgets/popup_window.py b/widgets/popup_window.py index d6d600c..be1df90 100644 --- a/widgets/popup_window.py +++ b/widgets/popup_window.py @@ -1,12 +1,11 @@ import contextlib -import gi # type: ignore -from gi.repository import Gdk, Gtk, GtkLayerShell # type: ignore -from widgets.wayland import WaylandWindow +from fabric.utils import Gdk, Gtk +from fabric.widgets.wayland import WaylandWindow +from gi.repository import GtkLayerShell + from utils.monitors import HyprlandWithMonitors -gi.require_version("GtkLayerShell", "0.1") - class PopupWindow(WaylandWindow): """A simple popover window that can point to a widget.""" @@ -114,7 +113,10 @@ class PopupWindow(WaylandWindow): monitor = self._hyprland.display.get_monitor(current_monitor_id) monitor_geometry = monitor.get_geometry() monitor_x, monitor_y = monitor_geometry.x, monitor_geometry.y - monitor_width, monitor_height = monitor_geometry.width, monitor_geometry.height + monitor_width, monitor_height = ( + monitor_geometry.width, + monitor_geometry.height, + ) else: # Fallback to default screen screen = Gdk.Screen.get_default() @@ -136,8 +138,7 @@ class PopupWindow(WaylandWindow): if self._is_centered: # Calculate centered position with boundary checking centered_x = ( - (monitor_width / 2 - self._parent.get_allocated_width() / 2) - - width / 2 + (monitor_width / 2 - self._parent.get_allocated_width() / 2) - width / 2 ) + coords_centered[0] # Apply boundary checking only if enabled diff --git a/widgets/wayland.py b/widgets/wayland.py deleted file mode 100644 index b7c76aa..0000000 --- a/widgets/wayland.py +++ /dev/null @@ -1,370 +0,0 @@ -import re -from collections.abc import Iterable -from enum import Enum -from typing import Literal, cast - -import cairo -import gi -from gi.repository import Gdk, GObject, Gtk -from loguru import logger - -from fabric.core.service import Property -from fabric.utils.helpers import extract_css_values, get_enum_member -from fabric.widgets.window import Window - -gi.require_version("Gtk", "3.0") - -try: - gi.require_version("GtkLayerShell", "0.1") - from gi.repository import GtkLayerShell -except: - raise ImportError( - "looks like we don't have gtk-layer-shell installed, make sure to install it first (as well as using wayland)" - ) - - -class WaylandWindowExclusivity(Enum): - NONE = 1 - NORMAL = 2 - AUTO = 3 - - -class Layer(GObject.GEnum): - BACKGROUND = 0 - BOTTOM = 1 - TOP = 2 - OVERLAY = 3 - ENTRY_NUMBER = 4 - - -class KeyboardMode(GObject.GEnum): - NONE = 0 - EXCLUSIVE = 1 - ON_DEMAND = 2 - ENTRY_NUMBER = 3 - - -class Edge(GObject.GEnum): - LEFT = 0 - RIGHT = 1 - TOP = 2 - BOTTOM = 3 - ENTRY_NUMBER = 4 - - -class WaylandWindow(Window): - @Property( - Layer, - flags="read-write", - default_value=Layer.TOP, - ) - def layer(self) -> Layer: # type: ignore - return self._layer # type: ignore - - @layer.setter - def layer( - self, - value: Literal["background", "bottom", "top", "overlay"] | Layer, - ) -> None: - self._layer = get_enum_member(Layer, value, default=Layer.TOP) - return GtkLayerShell.set_layer(self, self._layer) - - @Property(int, "read-write") - def monitor(self) -> int: - if not (monitor := cast(Gdk.Monitor, GtkLayerShell.get_monitor(self))): - return -1 - display = monitor.get_display() or Gdk.Display.get_default() - for i in range(0, display.get_n_monitors()): - if display.get_monitor(i) is monitor: - return i - return -1 - - @monitor.setter - def monitor(self, monitor: int | Gdk.Monitor) -> bool: - if isinstance(monitor, int): - display = Gdk.Display().get_default() - monitor = display.get_monitor(monitor) - return ( - (GtkLayerShell.set_monitor(self, monitor), True)[1] - if monitor is not None - else False - ) - - @Property(WaylandWindowExclusivity, "read-write") - def exclusivity(self) -> WaylandWindowExclusivity: - return self._exclusivity - - @exclusivity.setter - def exclusivity( - self, value: Literal["none", "normal", "auto"] | WaylandWindowExclusivity - ) -> None: - value = get_enum_member( - WaylandWindowExclusivity, value, default=WaylandWindowExclusivity.NONE - ) - self._exclusivity = value - match value: - case WaylandWindowExclusivity.NORMAL: - return GtkLayerShell.set_exclusive_zone(self, True) - case WaylandWindowExclusivity.AUTO: - return GtkLayerShell.auto_exclusive_zone_enable(self) - case _: - return GtkLayerShell.set_exclusive_zone(self, False) - - @Property(bool, "read-write", default_value=False) - def pass_through(self) -> bool: - return self._pass_through - - @pass_through.setter - def pass_through(self, pass_through: bool = False): - self._pass_through = pass_through - region = cairo.Region() if pass_through is True else None - self.input_shape_combine_region(region) - del region - return - - @Property( - KeyboardMode, - "read-write", - default_value=KeyboardMode.NONE, - ) - def keyboard_mode(self) -> KeyboardMode: - return self._keyboard_mode - - @keyboard_mode.setter - def keyboard_mode( - self, - value: ( - Literal[ - "none", - "exclusive", - "on-demand", - "entry-number", - ] - | KeyboardMode - ), - ): - self._keyboard_mode = get_enum_member( - KeyboardMode, value, default=KeyboardMode.NONE - ) - return GtkLayerShell.set_keyboard_mode(self, self._keyboard_mode) - - @Property(tuple[Edge, ...], "read-write") - def anchor(self): - return tuple( - x - for x in [ - Edge.TOP, - Edge.RIGHT, - Edge.BOTTOM, - Edge.LEFT, - ] - if GtkLayerShell.get_anchor(self, x) - ) - - @anchor.setter - def anchor(self, value: str | Iterable[Edge]) -> None: - self._anchor = value - if isinstance(value, (list, tuple)) and all( - isinstance(edge, Edge) for edge in value - ): - for edge in [ - Edge.TOP, - Edge.RIGHT, - Edge.BOTTOM, - Edge.LEFT, - ]: - if edge not in value: - GtkLayerShell.set_anchor(self, edge, False) - GtkLayerShell.set_anchor(self, edge, True) - return - elif isinstance(value, str): - for edge, anchored in WaylandWindow.extract_edges_from_string( - value - ).items(): - GtkLayerShell.set_anchor(self, edge, anchored) - - return - - @Property(tuple[int, ...], flags="read-write") - def margin(self) -> tuple[int, ...]: - return tuple( - GtkLayerShell.get_margin(self, x) - for x in [ - Edge.TOP, - Edge.RIGHT, - Edge.BOTTOM, - Edge.LEFT, - ] - ) - - @margin.setter - def margin(self, value: str | Iterable[int]) -> None: - for edge, mrgv in WaylandWindow.extract_margin(value).items(): - GtkLayerShell.set_margin(self, edge, mrgv) - return - - @Property(object, "read-write") - def keyboard_mode(self): - kb_mode = GtkLayerShell.get_keyboard_mode(self) - if GtkLayerShell.get_keyboard_interactivity(self): - kb_mode = KeyboardMode.EXCLUSIVE - return kb_mode - - @keyboard_mode.setter - def keyboard_mode( - self, - value: Literal["none", "exclusive", "on-demand"] | KeyboardMode, - ): - return GtkLayerShell.set_keyboard_mode( - self, - get_enum_member( - KeyboardMode, - value, - default=KeyboardMode.NONE, - ), - ) - - def __init__( - self, - layer: Literal["background", "bottom", "top", "overlay"] | Layer = Layer.TOP, - anchor: str = "", - margin: str | Iterable[int] = "0px 0px 0px 0px", - exclusivity: ( - Literal["auto", "normal", "none"] | WaylandWindowExclusivity - ) = WaylandWindowExclusivity.NONE, - keyboard_mode: ( - Literal["none", "exclusive", "on-demand"] | KeyboardMode - ) = KeyboardMode.NONE, - pass_through: bool = False, - monitor: int | Gdk.Monitor | None = None, - title: str = "fabric", - type: Literal["top-level", "popup"] | Gtk.WindowType = Gtk.WindowType.TOPLEVEL, - child: Gtk.Widget | None = None, - name: str | None = None, - visible: bool = True, - all_visible: bool = False, - style: str | None = None, - style_classes: Iterable[str] | str | None = None, - tooltip_text: str | None = None, - tooltip_markup: str | None = None, - h_align: ( - Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None - ) = None, - v_align: ( - Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None - ) = None, - h_expand: bool = False, - v_expand: bool = False, - size: Iterable[int] | int | None = None, - **kwargs, - ): - Window.__init__( - self, - title=title, - type=type, - child=child, - name=name, - visible=False, - all_visible=False, - style=style, - style_classes=style_classes, - tooltip_text=tooltip_text, - tooltip_markup=tooltip_markup, - h_align=h_align, - v_align=v_align, - h_expand=h_expand, - v_expand=v_expand, - size=size, - **kwargs, - ) - self._layer = Layer.ENTRY_NUMBER - self._keyboard_mode = KeyboardMode.NONE - self._anchor = anchor - self._exclusivity = WaylandWindowExclusivity.NONE - self._pass_through = pass_through - - GtkLayerShell.init_for_window(self) - GtkLayerShell.set_namespace(self, title) - self.connect( - "notify::title", - lambda *_: GtkLayerShell.set_namespace(self, self.get_title()), - ) - if monitor is not None: - self.monitor = monitor - self.layer = layer - self.anchor = anchor - self.margin = margin - self.keyboard_mode = keyboard_mode - self.exclusivity = exclusivity - self.pass_through = pass_through - ( - self.show_all() - if all_visible is True - else self.show() if visible is True else None - ) - - def steal_input(self) -> None: - return GtkLayerShell.set_keyboard_interactivity(self, True) - - def return_input(self) -> None: - return GtkLayerShell.set_keyboard_interactivity(self, False) - - # custom overrides - def show(self) -> None: - super().show() - return self.do_handle_post_show_request() - - def show_all(self) -> None: - super().show_all() - return self.do_handle_post_show_request() - - def do_handle_post_show_request(self) -> None: - if not self.get_children(): - logger.warning( - "[WaylandWindow] showing an empty window is not recommended, some compositors might freak out." - ) - self.pass_through = self._pass_through - return - - @staticmethod - def extract_anchor_values(string: str) -> tuple[str, ...]: - """ - extracts the geometry values from a given geometry string. - - :param string: the string containing the geometry values. - :type string: str - :return: a list of unique directions extracted from the geometry string. - :rtype: list - """ - direction_map = {"l": "left", "t": "top", "r": "right", "b": "bottom"} - pattern = re.compile(r"\b(left|right|top|bottom)\b", re.IGNORECASE) - matches = pattern.findall(string) - return tuple(set(tuple(direction_map[match.lower()[0]] for match in matches))) - - @staticmethod - def extract_edges_from_string(string: str) -> dict["Edge", bool]: - anchor_values = WaylandWindow.extract_anchor_values(string.lower()) - return { - Edge.TOP: "top" in anchor_values, - Edge.RIGHT: "right" in anchor_values, - Edge.BOTTOM: "bottom" in anchor_values, - Edge.LEFT: "left" in anchor_values, - } - - @staticmethod - def extract_margin(input: str | Iterable[int]) -> dict["Edge", int]: - margins = ( - extract_css_values(input.lower()) - if isinstance(input, str) - else ( - input - if isinstance(input, (tuple, list)) and len(input) == 4 - else (0, 0, 0, 0) - ) - ) - return { - Edge.TOP: margins[0], - Edge.RIGHT: margins[1], - Edge.BOTTOM: margins[2], - Edge.LEFT: margins[3], - }