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

Implement basic Linux support #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import UWPNoise from '../img/uwp-noise.png';
import Search from './Search.js';
import Games from './games.js';
import Import from './Import.js';
import Remote from './Remote.js';

// Using window.require so babel doesn't change the node require
const electron = window.require('electron');
const remote = electron.remote;
const remote = new Remote(electron.remote);

// Log renderer errors
const log = window.require('electron-log');
Expand Down Expand Up @@ -75,8 +76,8 @@ class App extends React.Component {
}

render() {
const accentColor = remote.systemPreferences.getAccentColor();
const navWidth = 48;
const accentColor = remote.systemPreferences.getAccentColor();

const navigationTopNodes = [
<SplitViewCommand key="0" label="Library" icon={'Library'} onClick={() => this.handleNavRedirect('/')} />,
Expand Down
28 changes: 28 additions & 0 deletions src/js/Remote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export class Remote {
constructor(remote) {
this.remote = remote;
this.platform = process.platform;
this.systemPreferences = new SystemPreferences(this.remote);
}

getCurrentWindow() {
return this.remote.getCurrentWindow();
}
}

class SystemPreferences {
constructor(remote) {
this.remote = remote;
}

getAccentColor() {
if (process.platform === 'win32') {
return this.remote.getAccentColor();
} else {
// TODO: change this hard-coded colour
return '00FF00';
}
}
}

export default Remote;
42 changes: 28 additions & 14 deletions src/js/Steam.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Registry = window.require('winreg');
const Store = window.require('electron-store');
const fs = window.require('fs');
const os = window.require('os');
const {join} = window.require('path');
const VDF = window.require('@node-steam/vdf');
const shortcut = window.require('steam-shortcut-editor');
Expand All @@ -24,28 +25,41 @@ class Steam {
return resolve(this.steamPath);
}

const key = new Registry({
hive: Registry.HKCU,
key: '\\Software\\Valve\\Steam'
});
if (process.platform === 'win32') {
const key = new Registry({
hive: Registry.HKCU,
key: '\\Software\\Valve\\Steam'
});

key.values((err, items) => {
let steamPath = false;
key.values((err, items) => {
let steamPath = false;

items.forEach((item) => {
if (item.name === 'SteamPath') {
steamPath = item.value;
items.forEach((item) => {
if (item.name === 'SteamPath') {
steamPath = item.value;
}
});

if (steamPath) {
this.steamPath = steamPath;
log.info(`Got Steam path: ${steamPath}`);
resolve(steamPath);
} else {
reject(new Error('Could not find Steam path.'));
}
});
} else if (process.platform === 'linux') {
// TODO: add support for Steam in other locations than default
const steamPath = `${os.homedir()}/.steam/steam`;

if (steamPath) {
this.steamPath = steamPath;
log.info(`Got Steam path: ${steamPath}`);
if (fs.existsSync(steamPath)) {
resolve(steamPath);
} else {
reject(new Error('Could not find Steam path.'));
reject(new Error(`Steam was not found in default location (${steamPath})`));
}
});
} else {
reject(new Error(`getSteamPath() has no code path for platform "${process.platform}"`));
}
});
}

Expand Down