[LUA] Set variables according to if file exists


 
Thread Tools Search this Thread
Top Forums Programming [LUA] Set variables according to if file exists
# 1  
Old 06-29-2015
[LUA] Set variables according to if file exists

Heya

I'm using Awesome WM with the Vicious widget library.
As i'm using multi boot, Win8, Fedora and Arch, i have my WM-Config shared accross my GNU/Linux installations.

The regarding snippet:
Code:
-- Functions
	-- Its just a workaround for an 'unstable' 'hwmon/hwmon[12]' definition of Fedora21 - Rawhide
	-- Function (only) from: http://stackoverflow.com/questions/4990990/lua-check-if-a-file-exists
	function file_exists(name)
		local f=io.open(name,"r")
		if f~=nil then io.close(f) return true else return false end
	end
-- Apps - system specific
	editor = os.getenv("EDITOR") or "notepadqq"
	if file_exists("/etc/favicon.png")
	then	-- Its fedora / I have my rpm repo
		--editor = os.getenv("EDITOR") or "notepadqq"
		editor_cmd = terminal .. " -e " .. editor
		
		os_icon = wibox.widget.imagebox()
		os_icon:set_image("/etc/favicon.png")
	else	-- Probably Arch
		--editor = os.getenv("EDITOR") or "pluma"
		editor_cmd = terminal .. " -e " .. editor
		
		os_icon = wibox.widget.imagebox()
		ARCH_IMG = awful.util.getdir("config") .. "themes/icons/arch-blue-transparent_smaller.png"
		os_icon:set_image(ARCH_IMG)
		--os_icon:set_image(awful.util.getdir("config") .. "themes/icons/arch-blue-transparent_small.png")
	end
-- .....
	mylauncher = awful.widget.launcher({ image = beautiful.os_icon,
		                             menu = mymainmenu })

The full config, without the changes can be seen at: https://github.com/sri-arjuna/awesom.../master/rc.lua

Issue is, it loads successfull, as in: no warnings or error messages shown.
BUT, i dont get the the distro icon shown, and therefor no menu is available (other than the hotkey to show it).
(EDIT: in neither of the distros, used to work in fedora, see remote code)

Eventhough i did quite a few changes at that lua code, i dont 'know' lua well enough to figure this...

Any advices please?
Tia

Last edited by sea; 06-29-2015 at 11:58 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If a string variable value exists in a set of values

Can some one please help me with the syntax in shell script for the below : if $var1 exists in ('val1','val2','val3') I want to execute a set of commands if the value of var1 variable matches any one of the given string values. Please let me know if there are any other option to go by. ... (10 Replies)
Discussion started by: Pandee
10 Replies

2. Shell Programming and Scripting

[LUA-Awesome] Can i use $XDG_XY_DIR inside a lua script?

Heyas I'm a fan of AwesomeWM, but i had failed to learn lua, though, i'm quite satisfied with the cofniguration i have by now. Either way, i'd like to know if i could 'call' those XDG_XY_DIR variables which are located on my linux ~/.config/user-dirs.dirs. While to call scripts i use... (0 Replies)
Discussion started by: sea
0 Replies

3. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

4. Shell Programming and Scripting

File exists, but cannot be opened.How to check- whether it could be opened to read when it exists

Hi #Testing for file existence if ; then echo 'SCHOOL data is available for processing' else echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING' : i wrote a script, where it begins by checking if file exists or not. If it exists, it truncates the database... (2 Replies)
Discussion started by: rxg
2 Replies

5. Shell Programming and Scripting

ENQUIRY WHETHER SCRIPT FOR DETECTING WORDS FROM A SET OF LETTERS EXISTS

Hello, I am interested in finding out whether someone has a perl or awk script which takes a set of letters such as wak and referring to a dictionary spews out all possible forms such as awk, kaw etc. If someone has such a script, could it be put up please. The script should handle Unicode. Many... (0 Replies)
Discussion started by: gimley
0 Replies

6. Shell Programming and Scripting

Set variables from file, then loop

Hello, I am very, very new to shell scripting, but what I'm attempting to do is read in a list of user ID's to create on a database system from a CSV flat file, and for each entry run the "create user" script. I've gotten pretty far but I'm having trouble with the looping mechanism.... Any... (8 Replies)
Discussion started by: jkarren
8 Replies

7. Shell Programming and Scripting

Need to SET Environment variables

Hi Could you please tell me how to set environment variables in Unix ksh. And how can acess those varibles in shell scripts ( Please give the code with an example) For my scenario. We have written number of shell scripts with hard coded username and password. But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies

8. AIX

How to set permanent variables

I set my TERM variable to work with SMIT and everything works fine but when I logged out and log in again I have to set the variable again. How can I set a permanent variable into the system so it will be as I wish even if a reboot is needed? I set variables this way: export VAR=value (7 Replies)
Discussion started by: agasamapetilon
7 Replies

9. Shell Programming and Scripting

Ksh script - Design ? - Search file and set variables

Hi - I'm trying to think of a clever way to write a shell script (trying to stay w/ ksh as that's what I know the best...) that will resolve the following problem: Problem - On a daily basis I have to email folks who are on-call to remind them. I was hoping to script this out so I could have... (9 Replies)
Discussion started by: littlefrog
9 Replies

10. UNIX for Dummies Questions & Answers

Using Variables to Set Other Variables

I have a script that I'm trying to shorten (below) by removing repetitive code. if ] then commodity_ndm_done=Y fi if ] then customer_ndm_done=Y fi if ] then department_ndm_done=Y fi if ] then division_ndm_done=Y fi (3 Replies)
Discussion started by: superdelic
3 Replies
Login or Register to Ask a Question