diff --git a/ColorChangerService.sln b/ColorChangerService.sln index 3b00c41..aeeb536 100644 --- a/ColorChangerService.sln +++ b/ColorChangerService.sln @@ -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 diff --git a/ColorChangerService/ChangeTheme.bat b/ColorChangerService/ChangeTheme.bat new file mode 100644 index 0000000..b24d90b --- /dev/null +++ b/ColorChangerService/ChangeTheme.bat @@ -0,0 +1,2 @@ +%1 +taskkill /F /IM systemsettings.exe \ No newline at end of file diff --git a/ColorChangerService/ColorChanger.cs b/ColorChangerService/ColorChanger.cs index 17c193a..8749a31 100644 --- a/ColorChangerService/ColorChanger.cs +++ b/ColorChangerService/ColorChanger.cs @@ -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. // @@ -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 { @@ -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) { diff --git a/ColorChangerService/ColorChangerService.csproj b/ColorChangerService/ColorChangerService.csproj index 2400961..b046938 100644 --- a/ColorChangerService/ColorChangerService.csproj +++ b/ColorChangerService/ColorChangerService.csproj @@ -88,6 +88,7 @@ + @@ -95,9 +96,10 @@ - - Designer + + Always + diff --git a/ColorChangerService/Properties/AssemblyInfo.cs b/ColorChangerService/Properties/AssemblyInfo.cs index 262e2de..cc5c39a 100644 --- a/ColorChangerService/Properties/AssemblyInfo.cs +++ b/ColorChangerService/Properties/AssemblyInfo.cs @@ -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. // @@ -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("")] @@ -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")] diff --git a/ColorChangerService/Service.cs b/ColorChangerService/Service.cs index b89562e..c920eb1 100644 --- a/ColorChangerService/Service.cs +++ b/ColorChangerService/Service.cs @@ -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. // @@ -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"; diff --git a/ColorChangerService/ThemeChanger.cs b/ColorChangerService/ThemeChanger.cs new file mode 100644 index 0000000..27ce4cf --- /dev/null +++ b/ColorChangerService/ThemeChanger.cs @@ -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 . +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); + } + } + } +} \ No newline at end of file diff --git a/Inno Setup/Setup.iss b/Inno Setup/Setup.iss index f0ff496..4468c68 100644 --- a/Inno Setup/Setup.iss +++ b/Inno Setup/Setup.iss @@ -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/ @@ -49,11 +49,12 @@ 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 @@ -61,14 +62,33 @@ Filename: "{app}\moveVivaldiFiles.exe"; Parameters: """{code:GetVivaldiPath}"""; 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//AppData/Local/Microsoft/Windows/Themes/.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; @@ -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; @@ -173,6 +193,7 @@ end; procedure InitializeWizard; begin + InitializeWizard0 InitializeWizard1 InitializeWizard2 InitializeWizard3 diff --git a/MoveDLLs/Properties/AssemblyInfo.cs b/MoveDLLs/Properties/AssemblyInfo.cs index d7fbbdf..b9fe8c5 100644 --- a/MoveDLLs/Properties/AssemblyInfo.cs +++ b/MoveDLLs/Properties/AssemblyInfo.cs @@ -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")] diff --git a/MoveVivaldiFiles/Properties/AssemblyInfo.cs b/MoveVivaldiFiles/Properties/AssemblyInfo.cs index ab01d62..1baa5d7 100644 --- a/MoveVivaldiFiles/Properties/AssemblyInfo.cs +++ b/MoveVivaldiFiles/Properties/AssemblyInfo.cs @@ -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")] diff --git a/README.md b/README.md index 3bf007d..334d1b3 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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//AppData/Local/Microsoft/Windows/Themes/.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 @@ -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 @@ -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 @@ -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.