Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from sirfredrick231/add-windows-theming
Browse files Browse the repository at this point in the history
Add windows theming
  • Loading branch information
sirfredrick authored Jul 27, 2019
2 parents 7faaaea + 61c7713 commit aa44dd5
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 41 deletions.
4 changes: 2 additions & 2 deletions ColorChangerService.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorChangerService", "ColorChangerService\ColorChangerService.csproj", "{3B9ABB1F-B971-4CB9-BF8A-B445112C0294}"
ProjectSection(ProjectDependencies) = postProject
Expand Down
2 changes: 2 additions & 0 deletions ColorChangerService/ChangeTheme.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%1
taskkill /F /IM systemsettings.exe
23 changes: 17 additions & 6 deletions ColorChangerService/ColorChanger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2018 Jeffrey Tucker
// Copyright (C) 2018, 2019 Jeffrey Tucker
//
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//
Expand All @@ -23,14 +23,14 @@ public class ColorChanger
readonly IRGBFusionMotherboard motherboardLEDs = new LazyMotherboard();
readonly Pubnub pubnub;
readonly string[] channel = { "Vivaldi RGB" };

string path = System.Reflection.Assembly.GetEntryAssembly().Location;

public ColorChanger(EventLog log)
{
this.log = log;
PNConfiguration config = new PNConfiguration();
string configKey = "";
string path = System.Reflection.Assembly.GetEntryAssembly().Location;

log.WriteEntry("The Service executable path is: " + path, EventLogEntryType.Information);
try
{
Expand Down Expand Up @@ -103,9 +103,20 @@ public void Stop()

public void ChangeColor(Color color)
{
PulseLedSetting setting = new PulseLedSetting(color, 100, 0, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3));
motherboardLEDs.SetAll(setting);
log.WriteEntry("Changed Color: to " + HexConverter(color), EventLogEntryType.Information, 20);
FileIniDataParser parser = new FileIniDataParser();
try
{
IniData themeData = parser.ReadFile(path.Substring(0, path.Length - 23) + "\\config.ini");
string themePath = themeData["themePaths"]["themePath"];
Console.WriteLine(themePath);
log.WriteEntry("Switching to theme: " + themePath);
ThemeChanger themeChanger = new ThemeChanger(log);
themeChanger.changeColor(color, themePath);
themeChanger.switchTheme(themePath);
log.WriteEntry("Changed Color: to " + HexConverter(color), EventLogEntryType.Information, 20);
} catch (Exception e) {
log.WriteEntry("Could not get theme path: " + e);
}
}
private static String HexConverter(Color color)
{
Expand Down
6 changes: 4 additions & 2 deletions ColorChangerService/ColorChangerService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ThemeChanger.cs" />
<Compile Include="ColorChanger.cs" />
<Compile Include="LazyMotherboard.cs" />
<Compile Include="Service.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
<None Include="ChangeTheme.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GLedApiDotNet\GLedApiDotNet.csproj">
Expand Down
8 changes: 4 additions & 4 deletions ColorChangerService/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2018 Jeffrey Tucker
// Copyright (C) 2018, 2019 Jeffrey Tucker
//
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//
Expand All @@ -17,7 +17,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ColorChangerService")]
[assembly: AssemblyCopyright("Copyright © Jeffrey Tucker 2018")]
[assembly: AssemblyCopyright("Copyright © Jeffrey Tucker 2018, 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -39,5 +39,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
6 changes: 3 additions & 3 deletions ColorChangerService/Service.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2018 Jeffrey Tucker
// Copyright (C) 2018, 2019 Jeffrey Tucker
//
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//
Expand All @@ -15,11 +15,11 @@ static class Service
{
static void Main(string[] args)
{
if (!EventLog.SourceExists("Color Changer Service"))
/*if (!EventLog.SourceExists("Color Changer Service"))
{
EventLog.CreateEventSource("Color Changer Service", "Application Log");
return;
}
}*/

EventLog log = new EventLog();
log.Source = "Color Changing Service";
Expand Down
82 changes: 82 additions & 0 deletions ColorChangerService/ThemeChanger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (C) 2019 Jeffrey Tucker
//
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IniParser;
using IniParser.Model;
using System.Drawing;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace ColorChangerService
{
public class ThemeChanger
{
readonly EventLog log;
public ThemeChanger(EventLog log)
{
this.log = log;
}
public Boolean switchTheme(string themePath)
{
string path = System.Reflection.Assembly.GetEntryAssembly().Location;
path = path.Substring(0, path.Length - 23);
try
{
String msg = String.Empty;
Process p = new Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
p.StartInfo.FileName = path + "ChangeTheme.bat";
p.StartInfo.Arguments = themePath;
log.WriteEntry("Running: " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
p.Start();
}
catch (Exception e)
{
log.WriteEntry("Could not load theme: " + e);
return false;
}
return true;
}
public void changeColor(Color color, string themePath)
{
string path = System.Reflection.Assembly.GetEntryAssembly().Location;
log.WriteEntry("The Service executable path is: " + path);
try
{
log.WriteEntry(color.GetHashCode().ToString());
FileIniDataParser parser = new FileIniDataParser();
try
{
//User does not want theme changing enabled See setup.iss
if (themePath.Equals("")) {
return;
}
IniData data = parser.ReadFile(themePath);
string colorHex = "0x" + color.A.ToString("X2") + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
data["VisualStyles"]["ColorizationColor"] = "0x" + color.A.ToString("X2") + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
log.WriteEntry(colorHex);
parser.WriteFile(themePath, data);

}
catch (Exception e)
{
log.WriteEntry("Could not parse .theme file: " + e);
}
}
catch (Exception e)
{
log.WriteEntry("Unable to write to theme file: " + e);
}
}
}
}
39 changes: 30 additions & 9 deletions Inno Setup/Setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{0CED4BED-BBDC-4957-8694-803498B0C3B0}
AppName=Vivaldi Color Changer Service
AppVersion=2.1.1
AppVerName=Vivaldi Color Changer Service 2.1.1
AppVersion=2.2.0
AppVerName=Vivaldi Color Changer Service 2.2.0
AppPublisher=Sir Fredrick
AppPublisherURL=https://sirfredrick.vivaldi.net/
AppSupportURL=https://github.com/sirfredrick231/VivaldiColorChanger/
Expand Down Expand Up @@ -49,26 +49,46 @@ Name: "{commondesktop}\Vivaldi Color Changer Service"; Filename: "{app}\ColorCha
[INI]
Filename: {app}\ColorChangerService\config.ini; Section: configKeys; Key: pubKey; String: " {code:GetPubKey} "
Filename: {app}\ColorChangerService\config.ini; Section: configKeys; Key: subKey; String: " {code:GetSubKey} "
Filename: {app}\ColorChangerService\config.ini; Section: themePaths; Key: themePath; String: " {code:GetThemePath} "

[Run]
Filename: "{tmp}\unzip.exe"; Parameters: "SDK.zip"; Flags: runascurrentuser skipifsilent
Filename: "{tmp}\MoveDLLs.exe"; Parameters: """{app}\ColorChangerService\"; Flags: runascurrentuser skipifsilent
Filename: "{app}\ColorChangerService\ColorChangerService.exe"; Parameters: "install --localsystem --autostart"; Description: "{cm:LaunchProgram,Vivaldi Color Changer Service}"; Flags: runascurrentuser skipifsilent
; Filename: "{tmp}\unzip.exe"; Parameters: "SDK.zip"; Flags: runascurrentuser skipifsilent
; Filename: "{tmp}\MoveDLLs.exe"; Parameters: """{app}\ColorChangerService\"; Flags: runascurrentuser skipifsilent
Filename: "{app}\ColorChangerService\ColorChangerService.exe"; Parameters: "install --interactive --autostart"; Description: "{cm:LaunchProgram,Vivaldi Color Changer Service}"; Flags: runascurrentuser skipifsilent
Filename: "{app}\ColorChangerService\ColorChangerService.exe"; Parameters: "start"; Flags: runascurrentuser skipifsilent
Filename: "{app}\moveVivaldiFiles.exe"; Parameters: """{code:GetVivaldiPath}"""; Flags: runascurrentuser skipifsilent

[UninstallRun]
Filename: "{app}\ColorChangerService\ColorChangerService.exe"; Parameters: "uninstall";

[UninstallDelete]
Type: files; Name: "{app}\ColorChangerService\GLedApi.dll"
Type: files; Name: "{app}\ColorChangerService\layout.ini"
Type: files; Name: "{app}\ColorChangerService\ycc.dll"
; Type: files; Name: "{app}\ColorChangerService\GLedApi.dll"
; Type: files; Name: "{app}\ColorChangerService\layout.ini"
; Type: files; Name: "{app}\ColorChangerService\ycc.dll"
Type: files; Name: "{app}\ColorChangerService\config.ini"

[Code]
#include "dwinshs.iss"
var
ThemePage : TInputQueryWizardPage;
procedure InitializeWizard0();
begin
ThemePage := CreateInputQueryPage(wpWelcome,
'Theme Path', 'Please enter the path to your current theme file. Leave blank to disable theme changing.',
'Default Path: "C://Users/<Username>/AppData/Local/Microsoft/Windows/Themes/<Name>.theme"');
ThemePage.Add('Theme Path: ', False);
end;
function Theme_NextButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;
function GetThemePath(Param: String): string;
begin
result := ThemePage.Values[0];
end;
var
AuthPage : TInputQueryWizardPage;
Expand Down Expand Up @@ -157,7 +177,7 @@ begin
WizardForm.NextButton.Enabled := False;
// Enable to continue after download successfully, save the remote file automatically
WizardForm.NextButton.Enabled :=
DwinsHs_ReadRemoteURL('https://www.gigabyte.com/WebPage/332/images/B18.0206.1.zip', 'My_App', rmGet,
DwinsHs_ReadRemoteURL('https://www.gigabyte.com/WebPage/332/images/B19.0311.1.zip', 'My_App', rmGet,
Response, Size, ExpandConstant('{tmp}') + '\SDK.zip', @OnRead) = READ_OK;
Downloaded := WizardForm.NextButton.Enabled;
end;
Expand All @@ -173,6 +193,7 @@ end;
procedure InitializeWizard;
begin
InitializeWizard0
InitializeWizard1
InitializeWizard2
InitializeWizard3
Expand Down
4 changes: 2 additions & 2 deletions MoveDLLs/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
4 changes: 2 additions & 2 deletions MoveVivaldiFiles/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Vivaldi Color Changer Service aims to bring the functionality of the changing ac
![Vivaldi Color Changer Service](https://i.imgur.com/EzRxdzV.png)
## Features
So what can this project do?
* This project updates your motherboard LEDs to match your Vivaldi Browser's accent color.
* This project updates your motherboard LEDs or Windows 10 Theme Color to match your Vivaldi Browser's accent color.
* Since this project has a separate Vivaldi Mod and Windows Service you can either just use the Vivaldi Mod to change other LEDs or you can change your motherboard LEDs by having another program talk with the Windows Service. The options are almost limitless!
* This project now has a EXE Installer!

#### Note:

This project currently only works with [Gigabyte RGB Fusion Motherboards](https://www.gigabyte.com/mb/rgb/) on Windows machines.
This project currently only has RGB working with [Gigabyte RGB Fusion Motherboards](https://www.gigabyte.com/mb/rgb/) on Windows machines. Theme changing works for all Windows 10 devices.

## Getting started

Expand All @@ -24,20 +24,28 @@ Once you are logged in create a new app and then copy the `Publish and Subscribe
Download the project binary Setup.exe installer:
[Binary Installer](https://github.com/sirfredrick231/VivaldiColorChanger/releases)
This project uses RGB Fusion SDK. The supported binaries can be found here
* Latest Version- [B18.0206.1.zip](https://www.gigabyte.com/WebPage/332/images/B18.0206.1.zip)
* Latest Version- [~~B18.0206.1.zip~~](https://www.gigabyte.com/WebPage/332/images/B18.0206.1.zip) download link is broken. If you still have the DLLs from the previous version move them into the Vivaldi Color Changer Service folder after installing and the RGB will still work.

**Note** If you are using this project Pre-Version 2.0.0 use:
* [B17.0926.1.zip](https://www.gigabyte.com/WebPage/332/images/B17.0926.1.zip)

## Installing
Just run `Setup.exe` and input you `Vivaldi Browser` path (Make sure to install the [Vivaldi Browser](https://vivaldi.com/download/) if you haven't already.) and your `Publish and Subscribe Keys`
Copy and Paste your PubNub Subsribe Key Below.
and then the installer will install and start the Windows Service.
Copy and Paste your PubNub Subscribe Key Below.
Then you need to enter the .theme file path. If you don't want Theme Changing just leave it blank and click next.
To turn your current theme into a .theme file got to `Settings -> Personalization -> Themes`. Then give your file a name (Do not include .theme). It can be found under `C://Users/<Username>/AppData/Local/Microsoft/Windows/Themes/<ThemeName>.theme`
Make sure to enable `Hidden Files` in the File Explorer to see the `AppData` folder.
and then the installer will install and start the Windows Service.

You will now be prompted for a login. Enter your Computer's Name (How it appears under your network) and Username in this format:
```shell
DOMAIN\username
```
then enter the password that you would normally log into your computer with.

Once you are done with that the installation should now be done! Wasn't that easier than you thought?

When you start Vivaldi go to a new website and see the color on your motherboard magically change! (Twitter and Youtube work well.)
When you start Vivaldi go to a new website and see the color on your motherboard (or Windows 10 Theme) magically change! (Twitter and Youtube work well.)

## Uninstalling

Expand All @@ -48,7 +56,7 @@ Follow the uninstall instructions and you should be back to a boring old setup!
## Developing

If you want to help develop this project, welcome aboard!
To get started, clone the repository and open the `solution` in [Visual Studio 2017](https://visualstudio.microsoft.com/downloads/). Right now the project is targeting `.NET 4.6.1`
To get started, clone the repository and open the `solution` in [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/). Right now the project is targeting `.NET 4.6.1`

```shell
git clone https://github.com/sirfredrick231/VivaldiColorChanger.git
Expand All @@ -75,13 +83,13 @@ to the body of `browser.html`
Then you can turn on the `Debugging for packed apps` flag at `vivaldi://flags` on your browser. Then right click the active tab and `Inspect` then you can see the Mod's console output.

### Deploying / Publishing
Before publish please use default Visual Studio 2017 formatting by clicking ctr+k an then ctr+d.
Before publish please use default Visual Studio 2019 formatting by clicking ctr+k an then ctr+d.

## Planned Features/Please help me do this!

* Support for more motherboard and peripheral brands RGB Software. Such as, [Aura Sync](https://www.asus.com/campaign/aura/us/index.html), [Mystic Light](https://www.msi.com/Landing/mystic-light-motherboard#extension) etc.
* Update [pubnub.js](https://github.com/pubnub/javascript/releases) and [GLedAPIDotNet](https://github.com/tylerszabo/RGB-Fusion-Tool) to their latest versions.
* Maybe have an MSI installer?
* ~~Update [pubnub.js](https://github.com/pubnub/javascript/releases) and [GLedAPIDotNet](https://github.com/tylerszabo/RGB-Fusion-Tool) to their latest versions.~~
* ~~Maybe have an MSI installer?~~
* Linux Version?

## Contributing
Expand All @@ -104,7 +112,7 @@ See `CONTRIBUTING.md` for the specifics.
## Copyright
GLedAPIDotNET from RGB-Fusion-Tool Copyright © 2018 Tyler Szabo

Installer, ColorChangerService, and custom.js, MoveDLLs, MoveVivaldiFiles, Setup.iss Copyright © 2018 Jeffrey Tucker
Installer, ColorChangerService, and custom.js, MoveDLLs, MoveVivaldiFiles, Setup.iss Copyright © 2018, 2019 Jeffrey Tucker

pubnub.js Copyright © 2013 PubNub Inc.

Expand Down

0 comments on commit aa44dd5

Please sign in to comment.