linux - how to make "xhost +local:host" be effective forever so I do not need to set it everytime the computer boots? -
i tried wirte command xhost +local:host
shell , write crontab excute shell. failed.
here's shell:
#!/bin/bash source /etc/profile export display=:0.0 /usr/bin/xhost +local:root
here's crontab:
@reboot /bin/bash /home/pi/shell2.sh 2>&1 >/dev/null | tee /home/pi/shell2.log
after rebooting,i checked log , says:
/usr/bin/xhost: unable open dispaly ":0.0"
i feel confused. can excute shell manually can't make excute automatilly when boots.and when excute xhost +local:host
on terminal works fine.
i typed env in terminal , result
xdg_vtnr=7 infinality_ft_autohint_horizontal_stem_darken_strength=10 ssh_agent_pid=1383 xdg_session_id=c1 sal_use_vclplugin=gtk clutter_im_module=xim xdg_greeter_data_dir=/var/lib/lightdm/data/pi term=xterm infinality_ft_autohint_vertical_stem_darken_strength=25 shell=/bin/bash xdg_menu_prefix=lxde-pi- infinality_ft_bold_embolden_x_value=0 infinality_ft_contrast=0 user=pi infinality_ft_grayscale_filter_strength=0 ls_colors=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: xdg_session_path=/org/freedesktop/displaymanager/session0 xdg_seat_path=/org/freedesktop/displaymanager/seat0 ssh_auth_sock=/tmp/ssh-r0hsj9vyfxkm/agent.1144 infinality_ft_fringe_filter_strength=0 infinality_ft_brightness=0 infinality_ft_use_various_tweaks=true infinality_ft_gamma_correction=0 100 xdg_config_dirs=/etc/xdg path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games desktop_session=lxde-pi qt_im_module=fcitx pwd=/home/pi xmodifiers=@im=fcitx lang=en_gb.utf-8 infinality_ft_filter_params=11 22 38 22 11 infinality_ft_use_known_settings_on_selected_fonts=true infinality_ft_stem_snapping_sliding_scale=40 infinality_ft_windows_style_sharpening_strength=10 infinality_ft_chromeos_style_sharpening_strength=0 infinality_ft_stem_alignment_strength=25 infinality_ft_autohint_snap_stem_height=100 gdmsession=lightdm-xsession _lxsession_pid=1144 shlvl=1 xdg_seat=seat0 home=/home/pi xdg_config_home=/home/pi/.config infinality_ft_bold_embolden_y_value=0 infinality_ft_global_embolden_y_value=0 logname=pi qt4_im_module=fcitx xdg_data_dirs=/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg dbus_session_bus_address=unix:abstract=/tmp/dbus-fbm7nlhtln,guid=863c2d8c9c28f93d365b95f0597af05d infinality_ft_stem_fitting_strength=25 infinality_ft_autohint_increase_glyph_heights=true textdomain=im-config xdg_runtime_dir=/run/user/1000 infinality_ft_global_embolden_x_value=0 display=:0.0 xdg_current_desktop=lxde gtk_im_module=fcitx textdomaindir=/usr/share/locale/ xauthority=/home/pi/.xauthority _=/usr/bin/env
why can't excute automatically??? can tell me how solve this? many many thanks!
sincerely,helen
because cron script not launched x session, need set display environment variable script: xhost +local:host
becomes display=:0 xhost +local:host
. know, crontab not inherit env, path must set or explicitly specified find location of xhost
, , of course $display
variable must set also. update: update xauthority=/home/pi/.xauthority
may help
Comments
Post a Comment