这是我第二次发布这个问题,因为整个情况最终比我想象的更令人困惑。
我正在尝试创建一个打开tmux的脚本,将其拆分为3个窗格,使它们水平放大,并在所有窗格中启动ncmpcpp。这是我设法编写的脚本:
#!/bin/sh
tmux new-session -d 'ncmpcpp'
printf 'creating session\n'
tmux split-window -h 'ncmpcpp'
printf 'window split 1\n'
tmux split-window -h 'ncmpcpp'
printf 'window split 2\n'
tmux select-layout even-horizontal
printf 'evening out panes\n'
tmux a #
printf 'attaching session\n'
我是编写脚本的初学者,如果这里的错误显而易见,那就很抱歉。 printfs就在那里,以便我可以确定脚本在哪里崩溃tmux。显然,它在tmux a #
崩溃了。
奇怪的是,崩溃立即发生。由于它消失得有多快,我无法截取屏幕截图。
terminate called after throwing an instance of `std::logic_error
what() : constructed window couldn't fit into terminal'
基本上,窗格太小,ncmpcpp无法启动。即使我可以手动以较小的终端启动ncmpcpp。
但是,经过一番乱搞,我不小心“有点”解决了这个问题。
我用脚本搞砸了,我最终得到了这个:
#!/bin/sh
printf '\033[8;29;252t'
tmux new-session -d
tmux select-layout even-horizontal
tmux send-keys -t 0 'tput cols' Enter
tmux split-window -h
sleep 1
tmux select-layout even-horizontal
tmux send-keys -t 1 'tput cols' Enter
tmux split-window -h
sleep 1
tmux select-layout even-horizontal
tmux send-keys -t 2 'tput cols' Enter
sleep 1
tmux send-keys -t 0 'ncmpcpp' Enter
tmux send-keys -t 1 'ncmpcpp' Enter
tmux send-keys -t 2 'ncmpcpp' Enter
tmux a #
在开始使用tmux之前需要3秒的暂停,有3个窗格,所有窗格都有ncmpcpp。
... 有时。
它不会一直有效,有时某些窗格会彻底崩溃,有时它们不会崩溃。
老实说,我真的很困惑这里发生了什么。我的猜测是窗格的大小记录不好,足以搞定每个窗格有多少列/行的值。但老实说,我很难过。
这就是为什么我要问这个 - ncmpcpp只在终端的大小足够大时启动。由于tmux用实际值来说明列是什么,是不是可以做我在标题中所说的事情?
答案 0 :(得分:3)
我认为这是不可能的,但我错过了一些东西。
tmux new-session -d
为了使ncmpcpp工作,需要指定实际会话的大小。这就是弄乱价值观的原因。为了解决这个问题,我这样做了:
tmux new-session -d -x 252 -y 29
之后运作良好。
这是最终的脚本:
#!/bin/sh
printf '\033[8;29;252t'
tmux new-session -d -x 252 -y 29
tmux select-layout even-horizontal
tmux split-window -h
tmux select-layout even-horizontal
tmux split-window -h
tmux select-layout even-horizontal
tmux send-keys -t 0 'ncmpcpp' Enter
tmux send-keys -t 1 'ncmpcpp' Enter
tmux send-keys -t 2 'ncmpcpp' Enter
tmux send-keys -t 1 '='
tmux send-keys -t 2 '8'
tmux a #
答案 1 :(得分:3)
所以
#!/bin/sh
printf '\033[8;29;252t'
tmux new-session -d -x 252 -y 29
tmux select-layout even-horizontal
tmux send-keys -t 0 'tput cols' Enter
tmux split-window -h
sleep 1
tmux select-layout even-horizontal
tmux send-keys -t 1 'tput cols' Enter
tmux split-window -h
sleep 1
tmux select-layout even-horizontal
tmux send-keys -t 2 'tput cols' Enter
sleep 1
tmux send-keys -t 0 'ncmpcpp -s playlist' Enter
tmux send-keys -t 1 'ncmpcpp -s media_library' Enter
tmux send-keys -t 2 'ncmpcpp -s clock' Enter
# help,playlist,browser,search_engine,media_library,
# playlist_editor,tag_editor,outputs,visualizer,clock
tmux a #
是你自己的答案。你有没有尝试改变ncmpcpp布局: (用-c调用)
ncmpcpp -c ~/.my_ncmpcpp.conf
#~/.my_ncmpcpp.conf
#edited from https://bbs.archlinux.org/viewtopic.php?pid=1236890#p1236890
song_list_format = "{$5%a $9}{$2%t$9}|{$7%f$9}$7$R{%b }{$3%4l$9}$9
song_status_format = "{{%a{ \"%b\"{ (%y)}} - }{%t}}|{%f}"
song_library_format = "{%N - }{%t}|{%f}"
now_playing_prefix = "$b"
alternative_header_first_line_format = "$b$8$aqqu$/a$9 $2{%t}|{%f}$9 $8$atqq$/a$9$/b"
alternative_header_second_line_format = "$b$8$aqqu$/a$9 $3{%b}|{%f}$9 $8$atqq$/a$9$/b"
song_columns_list_format = "(4)[blue]{n:#} (25)[blue]{a} (40)[blue]{t|f} (30)[blue]{b} (7f)[blue] {l}"
playlist_show_remaining_time = "yes"
playlist_separate_albums = "yes"
playlist_display_mode = "columns" (classic/columns)
browser_display_mode = "columns" (classic/columns)
search_engine_display_mode = "columns" (classic/columns)
progressbar_look = "✠❱•"
default_place_to_search_in = "database"
user_interface = "alternative"
header_visibility = "no"
titles_visibility = "yes"
show_hidden_files_in_local_browser = "no"
screen_switcher_mode = "browser, search_engine"
startup_screen = "search_engine"
ask_before_clearing_playlists = "yes"
clock_display_seconds = "yes"
display_volume_level = "yes"
display_bitrate = "no"
display_remaining_time = "yes"
regular_expressions = "extended"
ignore_leading_the = "yes"
mouse_support = "no"
enable_window_title = "yes"
allow_for_physical_item_deletion = "no"
external_editor = "vim"
use_console_editor = "yes"
colors_enabled = "yes"
header_window_color = "default"
main_window_color = "white"
progressbar_color = "green"
alternative_ui_separator_color = "red"
active_column_color = "red"
或者这可能会让你得到你想要的东西。
#!/bin/bash
SESSION=ncmpcpp
#url=https://bbs.archlinux.org/viewtopic.php?pid=1167179#p1167179
tmux -2 has-session -t $SESSION
if [ $? -eq 0 ]; then
tmux -2 attach -t $SESSION
exit 0;
fi
tmux -2 new-session -d -s $SESSION 'ncmpcpp -s playlist'
for i in "C-l" "Enter" "2"
do tmux -2 send-keys -t $SESSION:0.0 "$i"
done
tmux -2 set -t $SESSION -g status off
tmux -2 attach-session -t $SESSION