-
Notifications
You must be signed in to change notification settings - Fork 112
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
Added configure.sh and accompanying doc #82
Conversation
…dded a config_help to display help for configure.sh.
will give it a try tonight, thank you very much so far :) |
The script is not able to detect my (installed, but not active) xpadneo instance:
I guess this is because I had an older version installed - therefore you should also check for older versions and complain if the version does not fit the configure script :) Btw, there is a typo: "Installaion" Another thing is, that we should maybe additionaly permanently change the options using modprobe, as described in the README - this does also work if the module is not loaded :) |
Should the script run if a different version is detected? |
No, I think it would be enough to report an error - otherwise we would have to check if a given parameter is available in the installed version. That's too much I think :) |
Okay, so now the script checks if the version is the same as the number in the VERSION file in the xpadneo directory, and throws a warning before exiting. |
Perfect, the only thing missing now is the permanent change in /etc/modprobe.d/xpadneo.conf 😊 |
So just to be sure, in order to make changes permanent you put |
I hope this helps: https://wiki.archlinux.org/index.php/Kernel_module#Setting_module_options |
To take it short: yes! The only thing you need to take care about is to not overwrite existing options - you may need to parse an existing |
I'm a little confused about parsing the conf file. I was thinking of using
But I think that would cause duplicate lines if that option was changed more than once. Is that why you use tee in the example?
Also sorry, I didn't see the rest of this post, I didn't see where you asked about the variable. It was the |
Ah looks like I can use |
I need an opinion, should I add all of the config lines in |
I can remember that time :)
Right!
The latter option sounds better to me - in the end it is up to you, as long as the solution is robust and clean ;) |
No the file has that line in it by default. When I opened the config file that line was already in there. Is it supposed to be empty? EDIT: Also I agree that the best way is to use grep, but I have to put that in every option. I was thinking of making a function that does that and call that function, but I don't seem to understand how to pass parameters in functions in bash. Do you know how I could put this:
in a function so I don't have to type this out for each option. I know how to basically make a function in bash but I don't know how to make this function work with all the different options because I can't pass parameters like in a normal programming language. EDIT: Something like this seems to work, for figuring out what argument was passed to the script:
But I need to see if I can use grep to recognize what line to edit based on the argument passed, which is where my dilemma is. |
Everything is alright, this Line is in there to disable the faulty ERTM in Linux which prevents a sucessful connection with the gamepad 😊 |
I might have found a better aproach to using bash to parse the config file. I have seen that Python has a good library for this. What do you think? |
I don't like the idea of adding another dependency for this little script - not everybody has Python installed. If you don't like Shell scripts, then I would suggest perl, which is installed in most (all?) Distributions. 😊 |
Hmm never thought about perl. Is it a big language in linux? I'll look into it. If that doesn't work and time isn't an issue I will figure something out. If time is an issue I have a method that will work, it will just be redundant. I'm just really trying to use a function instead of writing the same code for each option to parse the config file. |
Time is not a problem - don't worry, that's the good thing in open source projects like this 😊 |
Awesome, I felt like I was taking too long. I'm glad, now I can take time to really learn some of these concepts. 😌 |
I opened this issue two month ago, take your time ;) |
Alright!! Give that a try, I rewrote the entire thing. I discovered this awesome handy tool that everyone else probably knows about already called getopt. Made it soooo much easier and cleaner. And I stuck everything into functions this time. I had a good time writing this one! 😃 |
Yeah, just give the suggestion a try - it's not super important to do it this way but it looks a bit clearer. |
No really a reason, that's just the way I grabbed the version number from the file name. I will use the one in
when i echo EDIT: I echoed the |
that's not so important, keep your way - we can do that later ;) |
Hey hey, I will give it a try today :) Thank you for your work! |
I like it! It works like a charm so far :) One thing I would like to mention: Are you going to fix the Shellcheck issues? Tell me if there is a reason to prefer the existing way over the one mentioned by codacy/code climate Ah and another thing: If the user does run the script without any option then - at least in my eyes - the help message should be shown too, right? So |
That is so great to hear!!
It was my pleasure and my joy, I have learned SO much in the past month or so working on this. It's been great!
There is no preference, that's just the only way I know to do it, but I would love to learn a better way. I tried copying this line from
however I could not get it to work right. When I echo
I can fix that no problem.
This is a great idea, I will add this as well. I never thought of it but it is true that most commands show the help menu when no arguments are called. |
So I took that line from the |
What's the Output of |
I'm out and about, I'll message you when I get home. |
Output of
Looks like I'm missing something. I'll see what I can find as far as a fix. |
…no args passed to display the help doc
configure.sh
Outdated
NAME="$0" | ||
OPTS=$(getopt -n "$NAME" -o hz:d:f:v:r: -l help,version,combined-z-axis:,debug-level:,disable-ff:,fake-dev-version:,trigger-rumble-damping: -- "$@") # Use getopt NOT getopts to parse arguments. | ||
|
||
echo "$VERSIONS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding an array without an index only gives the first element.
|
Ok I ran the uninstall script and it said it found 0 instances of xpadneo. |
Perfect, run the Install Script now - it should Work then |
Nice! It works now. I will replace that line and push that. |
configure.sh
Outdated
NAME="$0" | ||
OPTS=$(getopt -n "$NAME" -o hz:d:f:v:r: -l help,version,combined-z-axis:,debug-level:,disable-ff:,fake-dev-version:,trigger-rumble-damping: -- "$@") # Use getopt NOT getopts to parse arguments. | ||
|
||
echo "$VERSIONS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible misspelling: VERSIONS may not be assigned, but VERSION is.
|
||
# Check if version is out of date. | ||
function check_version { | ||
if [[ "$VERSION" != "$DETECTED_VERSION" ]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding an array without an index only gives the first element.
then | ||
echo "$NAME:Your version of xpadneo seems to be out of date." | ||
echo "$NAME:Please run ./update.sh from the git directory to update to the latest version." | ||
echo "$DETECTED_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding an array without an index only gives the first element.
|
||
## Version ## | ||
function display_version { | ||
echo "Xpadneo Version: $DETECTED_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding an array without an index only gives the first element.
Code Climate has analyzed commit b0d0c1a and detected 0 issues on this pull request. View more on Code Climate. |
Perfect :) I will merge your work into master tomorrow/later - I think it is ready now :) See ya later! |
Sounds great to me, thanks for you patience and letting me work on this. If I have an idea for your driver do I open a new issue? You might already be working on what I am thinking though. I was thinking that it would be great if this worked with the wireless USB dongle instead of just bluetooth. Let me know what you think. |
Merged by 769429b |
Ready for review and testing.