Debian Codegraph @

ui/razer-gamewrapper

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 [scip-shell system . . `[`. -n "$RAZER_MOUSE_DEV" ] || RAZER_MOUSE_DEV=mouse
4 [scip-shell system . . `[`. -n "$RAZER_MOUSE_GAMINGPROF" ] || RAZER_MOUSE_GAMINGPROF=5
5
6 usagescip-shell shell shell-project 0.0.0 usage().()
7 {
8 echoscip-shell system . . echo. "Usage razer-gamewrapper GAME [GAME-OPTIONS]"
9 echoscip-shell system . . echo.
10 echoscip-shell system . . echo. "Arguments:"
11 echoscip-shell system . . echo. " GAME is the game binary to execute"
12 echoscip-shell system . . echo. " GAME-OPTIONS are optional options to the game"
13 echoscip-shell system . . echo.
14 echoscip-shell system . . echo. "Environment variables:"
15 echoscip-shell system . . echo. " RAZER_MOUSE_DEV The id-string of the mouse."
16 echoscip-shell system . . echo. " Defaults to the first razer mouse."
17 echoscip-shell system . . echo. " RAZER_MOUSE_GAMINGPROF The profile ID of the gaming profile."
18 echoscip-shell system . . echo. " Defaults to '5'."
19 }
20
21 messagescip-shell shell shell-project 0.0.0 message().()
22 {
23 echoscip-shell system . . echo. "razer-gamewrapper: $*"
24 }
25
26 diescip-shell shell shell-project 0.0.0 die().()
27 {
28 messagescip-shell shell shell-project 0.0.0 message(). "$*"
29 cleanupscip-shell shell shell-project 0.0.0 cleanup().
30 exit 1
31 }
32
33 cleanupscip-shell shell shell-project 0.0.0 cleanup().()
34 {
35 [scip-shell system . . `[`. -n "$oldprof" ] && {
36 razercfg -d "$RAZER_MOUSE_DEV" -p "$oldprof" || diescip-shell shell shell-project 0.0.0 die(). "Failed to reset mouse profile"
37 }
38 }
39
40 terminatescip-shell shell shell-project 0.0.0 terminate().()
41 {
42 cleanupscip-shell shell shell-project 0.0.0 cleanup().
43 exit 1
44 }
45
46 oldprof=
47
48 [scip-shell system . . `[`. "$#" -eq 0 -o "$1" = "-h" -o "$1" = "--help" ] && { usagescip-shell shell shell-project 0.0.0 usage().; terminatescip-shell shell shell-project 0.0.0 terminate().; }
49 oldprof="$(razercfg -d "$RAZER_MOUSE_DEV" -P | awkscip-shell system . . awk. '{print $3;}')"
50 [scip-shell system . . `[`. -n "$oldprof" ] || diescip-shell shell shell-project 0.0.0 die(). "Failed to get current mouse profile"
51 trap terminate INT TERM
52 messagescip-shell shell shell-project 0.0.0 message(). "Old mouse profile: $oldprof"
53 messagescip-shell shell shell-project 0.0.0 message(). "Switching to gaming profile: $RAZER_MOUSE_GAMINGPROF"
54 razercfg -d "$RAZER_MOUSE_DEV" -p "$RAZER_MOUSE_GAMINGPROF" || diescip-shell shell shell-project 0.0.0 die(). "Failed to set mouse gaming profile"
55 messagescip-shell shell shell-project 0.0.0 message(). "Starting game: $*"
56 $@ || diescip-shell shell shell-project 0.0.0 die(). "Failed to start the game"
57 messagescip-shell shell shell-project 0.0.0 message(). "Switching to old profile: $oldprof"
58 cleanupscip-shell shell shell-project 0.0.0 cleanup().
59
60 exit 0