-
-
Notifications
You must be signed in to change notification settings - Fork 238
Steam #1763
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
Merged
Merged
Steam #1763
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,20 @@ | ||
| import { program } from "commander"; | ||
| import { Option, program } from "commander"; | ||
|
|
||
| program | ||
| .option('-p --path <path>', 'set launch path') | ||
| .option('-p, --path <path>', 'set launch path') | ||
| .option('-s, --steam', 'steam mode') | ||
| .option('-i, --install', 'run the driver installer') | ||
| .option( | ||
| '--skip-server-if-running', | ||
| 'gui will not launch the server if it is already running' | ||
| ) | ||
| .allowUnknownOption(); | ||
|
|
||
| if (process.platform === "linux") { | ||
| const noUdevOption = new Option('--no-udev', 'disable udev warning'); | ||
| noUdevOption.negate = false; | ||
| program.addOption(noUdevOption) | ||
| } | ||
|
|
||
| program.parse(process.argv); | ||
| export const options = program.opts(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import { useState, useEffect } from 'react'; | ||
| import { Button } from '@/components/commons/Button'; | ||
| import { BaseModal } from '@/components/commons/BaseModal'; | ||
| import { CheckboxInternal } from '@/components/commons/Checkbox'; | ||
| import { Typography } from '@/components/commons/Typography'; | ||
| import { useElectron } from '@/hooks/electron'; | ||
| import { useWebsocketAPI } from '@/hooks/websocket-api'; | ||
| import { RpcMessage, InstalledInfoResponseT } from 'solarxr-protocol'; | ||
| import { useConfig } from '@/hooks/config'; | ||
| import { useLocalization } from '@fluent/react'; | ||
|
|
||
| export function UdevRulesModal() { | ||
| const { config, setConfig } = useConfig(); | ||
| const { useRPCPacket, sendRPCPacket } = useWebsocketAPI(); | ||
| const electron = useElectron(); | ||
| const [udevContent, setUdevContent] = useState(''); | ||
| const [isUdevInstalledResponse, setIsUdevInstalledResponse] = useState(true); | ||
| const [showUdevWarning, setShowUdevWarning] = useState(false); | ||
| const [dontShowThisSession, setDontShowThisSession] = useState(false); | ||
| const [dontShowAgain, setDontShowAgain] = useState(false); | ||
| const { l10n } = useLocalization(); | ||
|
|
||
| const handleUdevContent = async () => { | ||
| if (electron.isElectron) { | ||
| const dir = await electron.api.getInstallDir(); | ||
| const rulesPath = `${dir}/69-slimevr-devices.rules`; | ||
| setUdevContent( | ||
| `cat ${rulesPath} | sudo sh -c 'tee /etc/udev/rules.d/69-slimevr-devices.rules >/dev/null && udevadm control --reload-rules && udevadm trigger'` | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| handleUdevContent(); | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| if (!config) throw 'Invalid state!'; | ||
| if (electron.isElectron) { | ||
| const isLinux = electron.data().os.type === 'linux'; | ||
| const udevMissing = !isUdevInstalledResponse; | ||
| const notHiddenGlobally = !config.dontShowUdevModal; | ||
| const notHiddenThisSession = !dontShowThisSession; | ||
| const shouldShow = | ||
| isLinux && udevMissing && notHiddenGlobally && notHiddenThisSession; | ||
| setShowUdevWarning(shouldShow); | ||
| } | ||
| }, [config, isUdevInstalledResponse, dontShowThisSession]); | ||
|
|
||
| useEffect(() => { | ||
| sendRPCPacket( | ||
| RpcMessage.InstalledInfoRequest, | ||
| new InstalledInfoResponseT() | ||
| ); | ||
| }, []); | ||
|
|
||
| useRPCPacket( | ||
| RpcMessage.InstalledInfoResponse, | ||
| ({ isUdevInstalled }: InstalledInfoResponseT) => { | ||
| setIsUdevInstalledResponse(isUdevInstalled); | ||
| } | ||
| ); | ||
|
|
||
| const handleModalClose = () => { | ||
| if (!config) throw 'Invalid State!'; | ||
| setConfig({ dontShowUdevModal: dontShowAgain }); | ||
| setDontShowThisSession(true); | ||
| }; | ||
|
|
||
| const copyToClipboard = () => { | ||
| navigator.clipboard.writeText(udevContent); | ||
| }; | ||
|
|
||
| return ( | ||
| <BaseModal isOpen={showUdevWarning} appendClasses={'w-full max-w-2xl'}> | ||
| <div className="flex w-full h-full flex-col gap-4"> | ||
| <div className="flex flex-col gap-3"> | ||
| <div className="flex flex-col gap-2"> | ||
| <Typography | ||
| variant="main-title" | ||
| id="install-info_udev-rules_modal_title" | ||
| /> | ||
| <Typography id="install-info_udev-rules_warning" /> | ||
| </div> | ||
| <div className="relative w-full max-w-2xl"> | ||
| <div className="absolute right-2 top-2"> | ||
| <Button variant="secondary" onClick={copyToClipboard}> | ||
| Copy | ||
| </Button> | ||
| </div> | ||
| <div className="bg-background-80 rounded-lg overflow-auto p-2 w-full h-[300px]"> | ||
| <pre className="text-wrap">{udevContent}</pre> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="flex justify-between gap-2"> | ||
| <CheckboxInternal | ||
| label={l10n.getString( | ||
| 'install-info_udev-rules_modal-dont-show-again_checkbox' | ||
| )} | ||
| name="dismiss-udev-rules-checkbox" | ||
| onChange={(e) => setDontShowAgain(e.currentTarget.checked)} | ||
| /> | ||
| <Button | ||
| variant="primary" | ||
| onClick={handleModalClose} | ||
| id="install-info_udev-rules_modal_button" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </BaseModal> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.