Skip to content

Implement Theme Packs #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Implement Theme Packs #79

wants to merge 3 commits into from

Conversation

bhh32
Copy link

@bhh32 bhh32 commented May 18, 2025

Theme Packs

The idea of a theme pack is that it bundles the color scheme and layout together in one package to be applied together into one coherent theme.

Implementation

Theme Pack Page

Consists of a form for creating a new theme pack at the top of the page. Underneath the Create New Theme section is the Available Themes section where the user can import a theme pack or apply a theme pack that has been either created or imported.

Created and imported theme packs can also be deleted/removed from the page.

Screenshot_2025-05-18_12-35-47

Screenshot_2025-05-18_12-36-00

Export Theme

After the user gives the theme a name, author, and description they click the export theme button. From here it exports the theme into the theme_packs directory of the application and becomes available in the Available Themes section.

Import Theme Pack

This button opens a native file dialog and allows the user to navigate to and select the theme pack file. COSMIC theme pack files are basically .ron with a .ctp extension to clearly define they are COSMIC theme pack files.

@bhh32
Copy link
Author

bhh32 commented May 18, 2025

I have some cosmetic changes I've made and forgot to push up that I'll get in the branch tomorrow. Basically labels that I forgot to change. I also have to make the page scrollable so the things aren't squashed in a shorter window resize. I also want to fix up the README to reflect the updated labels, remove anything I thought I'd need but didn't, and move the files being saved to the right directory instead of my debug directory. Other than those things, the functionality is there and can be tested.

@bhh32
Copy link
Author

bhh32 commented May 18, 2025

I have finished the implementation for theme packs. However, I did find a bug that I will file in the issues where Color Schemes are not being saved as system themes that the actual COSMIC config files do not match what is happening in Tweaks. The theme packs are grabbing the system panel layout as well as the system color scheme and saving them. When they are reapplied they're applying them as if they were the actual config files. This means I didn't find a way to have the color scheme get applied in the theme pack from a Tweaks applied color scheme and it saves what COSMIC has applied, not Tweaks.

The two test theme packs are available in the attached .zip file. The directory they should be placed in is ~/.local/share/theme-packs/cosmic/ if you want to test with them.

test_theme_packs.zip

@edfloreshz
Copy link
Member

Thanks for working on this, I'll review it as soon as I can.

@bhh32
Copy link
Author

bhh32 commented May 25, 2025

You're welcome. Also, just want to make sure it doesn't stall. Is there anything you need me to do for this?

@edfloreshz
Copy link
Member

I'll review the code tonight and get back to you on that.

@edfloreshz
Copy link
Member

After reviewing this I have some questions, how does theme packs differ from saving your current color scheme?

image

What I see is that they do the exact same thing, both save very similar data.

image
image

@bhh32
Copy link
Author

bhh32 commented May 26, 2025

After reviewing this I have some questions, how does theme packs differ from saving your current color scheme?

image

What I see is that they do the exact same thing, both save very similar data.

image

image

As far as the color scheme goes it is the same data, the theme pack idea is also combining the panel layout and settings. Packaging them all in one file and unpacking them out of that one file.

@edfloreshz
Copy link
Member

Gotcha, what I would suggest in order to avoid code repetition is that you leverage the functionality already implemented by the other pages and use that to create a theme pack file that simply points to existing files instead of saving that data again.

A more resilient approach would be to copy the config files from other pages and save them into a theme pack folder, and simply point to that data, this would avoid the issue of having corrupt theme packs if the data from other pages ever goes missing.

@bhh32
Copy link
Author

bhh32 commented May 27, 2025

That's kind of what it does already, just into its own file instead of a directory. It doesn't rely on any other files. It combines the currently set color scheme and layout into a single file. You can see in the screenshot of the Gotham theme pack file the highlighted part is the layout. The cool thing about this method is that a Custom Layout, as long as it's currently set, can be captured within the theme pack file, and it doesn't have to be one of the default Tweaks layouts. In fact, that's what you're seeing in the Gotham theme pack file screenshot. It includes my custom apps as well.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants