Coder Social home page Coder Social logo

Comments (7)

haideralipunjabi avatar haideralipunjabi commented on August 17, 2024

I don't understand why you think deviceid should be $3 instead of $2.
$0 is the function name, i.e show_menu here
$1 is devicename
$2 is deviceid
$3 is battery.

If the name and battery status appear in the menu, that means $1 and $3 are working properly.

from polybar-kdeconnect.

fuzxi avatar fuzxi commented on August 17, 2024

Because with the default settings, the battery status shows the device ID for me. Additionally, the other options didn't work at all until I replaced each $2 with $3.

from polybar-kdeconnect.

haideralipunjabi avatar haideralipunjabi commented on August 17, 2024

That is weird behaviour. I will do some tests and get back to you

from polybar-kdeconnect.

haideralipunjabi avatar haideralipunjabi commented on August 17, 2024

Can you provide me with info about the shell you are using?
I am not extremely knowledgeable about shell behaviours but I made the following test script

#!/usr/bin/env bash
func () {
echo $0 $1 $2 $3
}

and executed

. ./script.sh; func "arg1" "arg2" "arg3"

and got the following output

func arg1 arg2 arg3

which confirms that at least on my shell (zsh, and previously bash) $0 is the name of the function, $1 is the first argument and so on.
Can you test it and check what output you get?

from polybar-kdeconnect.

fuzxi avatar fuzxi commented on August 17, 2024

I'm using zsh. Per #6, shebangs don't seem to make any difference on my system, so I just symlinked /bin/bash to /bin/sh.

Running ./script.sh; func "arg1" "arg2" "arg3" in zsh returns func arg1 arg2 arg3, but so does simply inputting func "arg1" "arg2" "arg3".

Running . ./test.sh; func "arg1" "arg2" "arg3" in bash returns bash arg1 arg2 arg3.

from polybar-kdeconnect.

haideralipunjabi avatar haideralipunjabi commented on August 17, 2024

In any case, in the test script, $1 is arg1. This same behaviour should be happening in the main script as well. I still have no ideas on why this is happening. I will continue working on it.
Edit:
Since the output of the test script is correct, can you run the main script in shell and check how the variables work there?

from polybar-kdeconnect.

haideralipunjabi avatar haideralipunjabi commented on August 17, 2024

I have modified the script to use getopts. Hopefully it fixes the issue.

from polybar-kdeconnect.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.